我有以下数据集,描述了去办公室的交通工具和到达办公室所需的时间
getting_to_work <- data.frame(
mode = c(
"bike", "car", "bus", "car", "walk","bike", "car", "bike", "car", "car"
),
time_mins = c(25, 13, NA, 22, 65, 28, 15, 24, NA, 14)
)
getting_to_work <- subset(getting_to_work,!is.na(time_mins))
unique(getting_to_work$mode)
在这里,当我执行unique(getting_to_work$mode)
时,显示以下结果:
unique(getting_to_work$mode)
[1] bike car walk
Levels: bike bus car walk
在删除了NA的条目并将其分配给原始数据集之后,即使unique(getting_to_work$mode)
为什么以级别显示总线,也删除了“总线”的条目?
提前谢谢!