Assign the number 17 to the object ub
ub
ub
ub <- 17
ub
Create an array of numbers: 301, 978, and 101.
Assign it to the object “years”
years #replace this with your code
years
years <- c(301, 978, 101)
years
What’s the average of the array of numbers assigned to “years”?
(years)
mean(years)
Take a look at the structure of burgers:
str(burgers)
Consider this data frame burgers
How do you refer to the the shirt variable/column with []?
# Add to the line below
burgers
burgers[,4]
How do you refer to the the shirt variable/column with $?
# Add to the line below
burgers
burgers$shirt
Extract entire row for Linda using [].
# Add to the line below
burgers
burgers[2,]
Convert the id variable of the burgers data frame to numeric.
# Add to the line below
burgers$id <-
burgers$id
class(burgers$id)
burgers$id <- as.numeric(as.character(burgers$id))
burgers$id
class(burgers$id)
Note: Is the answer the same as above (correct) or is it 1-5 (false)?
Check if Gene’s age is 11.
Note: This is the last question in the section. And there is a bug that only some correct answers are recognized.
# Replace __ with the correct characters
age_test <- burgers$age[5] __ 11
age_test
# Replace __ with the correct characters
age_test <- burgers$age[5] == 11
age_test