我有一个larga数据库,我想用这段代码打印出每个因素中的元素数量:
summary(factor(Bond$Cf$ISIN, levels = Bond$ISIN), maxsum = 1000)
我在下面输出了这个输出。我的问题是:这是如何订购价值的?乍一看,我认为它根据每个因素中的值的数量对它进行排序,但之后我看到了NL0009054907
。它有7个元素,但不知何故它出现在4个元素的因子中。
DE000A1X3LN0 XS1002977103 XS1014670233 DE000CZ40JH0 XS1016720853 XS0973623514 DE000HSH4QN3 XS0997333223 DE000A13SWD8 DE000HSH4XP4
3 3 3 3 3 3 3 3 3 3
XS1033018158 XS1369254310 XS1041793123 XS1196748757 XS1043150462DE000CZ40K31 XS0187339600 XS0413584672 XS1046237431 DE000CB83CE3
3 3 3 3 3 3 3 3 3 4
XS1050665386 XS1385935769 FR0010743070 FR0011233337 XS0418053152 XS0914402887 NL0009054907 XS0984200617 XS0993272862 XS0423989267
4 4 4 4 4 4 7 4 4 4
XS0296306078 DE000CZ40KW7 XS1070100257 XS0996755350 ES03136793B0 XS0432092137 XS0429192767 DE000HV2AKV6 XS1077629225 XS1078760813
4 4 4 4 4 4 4 4 4 4
DE000HSH28Z5 DE000HSH2893 XS1080952960 DE000DB7UQ89 XS1084838496 XS1236611684 DE000HSH41B9 DE000CZ291M8 DE000HSH3AM1 DE000HSH28J9
4 4 4 4 4 4 4 4 4 4
答案 0 :(得分:2)
比较
x <- factor(rep(letters[1:3], 4:6))
summary(x)
# a b c
# 4 5 6
x <- factor(x, levels = letters[3:1])
summary(x)
# c b a
# 6 5 4
答案 1 :(得分:0)
如果x是data.frame summary.factor中的因子按频率排序
x <- factor(rep(letters[1:10], 1:10), levels = letters[1:10])
summary(data.frame(x = x))
# x
# j :10
# i : 9
# h : 8
# g : 7
# f : 6
# e : 5
# (Other):10