我有一个数据框
A B A E B E B C ..
我想将其转换为两个数据框
一个是计数A,B,C ..在第一列中出现的次数,另一个是计数A,B,B ..在第二列中出现的次数。
A 5 B 4 ...
你能给我一些建议吗?
谢谢
尝试plyr库:
library(plyr)
myDataFrame <- as.data.frame(cbind( c("A", "A", "B", "B", "B", "C"), c("B", "E", "E", "C", "C", "E") ))
count(myDataFrame[,1]) ##prints counts of first column
count(myDataFrame[,2]) ##prints counts of second column
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句