设置有序因子的水平
2018-01-06 本文已影响0人
esskeetit
factor is a categorical variable that has different flavors and levels
对因子做表格,查看每个级别的数量
table(reddit$employment.status)
查看因子的所有级别
levels(reddit$age.range)
画出因子的直方图图
qplot(data=reddit,x=age.range)
对因数age.range进行排序
reddit$age.range <- ordered(reddit$age.range,levels=c('Under 18','18-24','25-34','35-44',
'45-54','55-64','65 of Above'))
reddit$age.range <- factor(reddit$age.range,levels=c('Under 18','18-24','25-34','35-44',
'45-54','55-64','65 of Above'),ordered=T)