r_factors Flashcards

1
Q

Given the following vector:

  • sex_vector <- c(“Male”, “Female”, “Female”, “Male”, “Male”)

Convert “sex_vector” to a factor named “factor_sex_vector”

A

factor_sex_vector <- factor(sex_vector)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Given the following vector:

  • temperature_vector <- c(“High”, “Low”, “High”,”Low”, “Medium”)

Convert to a factor“factor_temperature_vector” with the following characteristics:

  • Levels in order of “Low”, “Medium”, “High”
A

factor_temperature_vector <- factor(temperature_vector, order=TRUE, levels = c(“Low”, “Medium”, “High”) )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly