设置有序因子的水平

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)

你可能感兴趣的:(设置有序因子的水平)