Chapter 17 Categorical variables
nominal variables: represent data that are unordered
<- c("green", "blue", "yellow")
colors factor(colors)
## [1] green blue yellow
## Levels: blue green yellow
Ordinal variables: ordered, ranked data
If you dont specify, R will do alphatecially
<- c("low", "high", "med", "med")
speed
factor(speed, ordered = TRUE)
## [1] low high med med
## Levels: high < low < med
If you specify:
<- c("low", "high", "med", "med")
speed
factor(speed,
levels = c("low", "med", "high"),
ordered = TRUE)
## [1] low high med med
## Levels: low < med < high
Grab a component from a list
= list(A = c("a, b, d"),
mylist cinema = ("stars"),
size = c(1, 2, 3, 4, 4))
Three ways to select a column
2]] mylist[[
## [1] "stars"
"cinema"]] mylist[[
## [1] "stars"
$cinema mylist
## [1] "stars"