我想将因子值转换为列表,我该怎么做? P.S。:Sry,我是R的新手
示例:我有以下因素:
> table(v)
v
(0,80] (80,500] (500,1000] (1000,10000] (10000,90000]
8259 2167 112 62 1
我怎么能得到:
c(8259,2167,112,62,1)
答案 0 :(得分:4)
使用unname()
:
x <- table(cut(runif(100), 5))
x
(0.00448,0.202] (0.202,0.399] (0.399,0.596] (0.596,0.794]
24 23 16 19
(0.794,0.991]
18
unname(x)
[1] 24 23 16 19 18
答案 1 :(得分:2)
您可以将表的结果转换为data.frame并:
as.data.frame(x)$Freq
[1] 28 13 20 20 19
答案 2 :(得分:2)
或者:
test <- as.vector(table(v)[])
test