# Who is it?
dwo_icecream <- 11 # days without icecream
favorite_food <- "risotto"
dog.lover = TRUE
enjoy_cold <- FALSE
dwo_icecream
[1] 11
[1] "risotto"
[1] FALSE
Marcio Diniz | Michael Luu
Cedars Sinai Medical Center
06 September, 2022
[1] 5 10 8 9 3
[1] 5
[1] "risotto" "TRUE" "FALSE" "5" "10" "8" "9"
[8] "3"
[1] 1 5 10 8 9 3
[1] 0 5 10 8 9 3
Some numeric vectors can also be created with easier approaches than use the function c:
Using the function rep:
Factors are special vectors that assume only pre-defined values defined using function factor:
It can be created based on a character vector:
[1] yes no yes yes yes
Levels: no yes
dwo_icecream pushups
[1,] 5 1
[2,] 10 10
[3,] 8 0
[4,] 9 30
[5,] 3 25
Conditions can combined:
A function takes inputs, make operations and gives back outputs;
Functions in R are organized in libraries;
Every function has a documentation that can be accessed with the operator ?.
Let’s create our own function to convert Fahrenheit to Celsius.
How would we do this conversion manually?
[1] 3.333333
[1] 3.333333 40.555556