关闭

R_factor函数

290人阅读 评论(0) 收藏 举报
分类:

status <- c("poor","improved","excellent","poor")
#表示有序型变量,用order=T指定,默认的排序规则是按字母顺序排
sta <- factor(status,order=T)

> sta
[1] poor      improved  excellent poor    
Levels: excellent < improved < poor

 

#按字母顺序达不到要求时,可以指定levels选项来覆盖默认排序
sta1 <- factor(status,order=TRUE,levels=c("poor","improved","excellent"))

sta1
[1] poor      improved  excellent poor    
Levels: poor < improved < excellent
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    最新评论