假设我有以下data.frame:
var=c("A","B","C","A","B","C","A","B","C")
time_sec=c(11.2,7.38,148.05,141.77,44.44,293.23,111.08,35.22,59.01)
dur_sec=c(7,3,2,1,5,2,4,6,2)
headers=c("var","time_sec","dur_sec")
g=data.frame(var, time_sec,dur_sec)
g
这是我的输出:
var time_sec duration_sec
A 11.2 7
B 7.38 3
C 148.05 2
A 141.77 1
B 44.44 5
C 293.23 2
A 111.08 4
B 35.22 6
C 59.01 2
在第1,第2,第3和第4分钟获取包含每个变量的频率数的表的最快方法是什么?另外,我想在输出中包含一个包含计数总和的列。
这是我想象的:
range (min) var Freq Sum (sec)
0-1 A 1 157.25
B 3
C 1
1-2 A 1 111.08
B 0
C 0
2-3 A 1 141.77
B 0
C 1
3-4 A 0 293.13
B 0
C 1