我有下面的R数据,我想通过计算每个因子的次数来处理这些数据。
structure(list(variable = structure(c(2L, 2L, 1L, 1L, 2L, 3L,
2L, 2L, 1L, 2L, 3L, 3L, 1L, 3L, 2L, 1L, 2L), .Label = c("A",
"B", "C"), class = "factor"), x = c(0, 0.01, 0.03, 0.05, 0.33,
0.38, 0.02, 0.03, 0.1, 0.15, 0.41, 0.42, 0.38, 0.07, 0.32, 0.05,
0.04)), .Names = c("variable", "x"), class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17"))
我最终得到的数据帧如下:
x A B C
0 00 0 1 0
0.01 0 2 0
0.02 0 3 0
0.03 1 4 0
0.04 1 5 0
0.05 3 5 0
0.07 3 5 1
and so on
到目前为止,我还没有发现任何直接的进展,因此我非常感谢帮助。