我正在尝试创建一个表,该表包含从属于给定时间{{}的两组(counts
和A
)中获取的变量的相对频率(B
) 1}}。我的问题是,如果一行以0秒开头(请参见intervals
),则该变量不会落在0-5秒start_sec
内,而是被标记为interval
(请参见输出)。我希望将这些情况包括在上述间隔之内。
这是一个虚拟的例子:
NA
group <- c("A","A","A","A","A","A","B","B","B")
person <- c("p1","p1","p1","p3","p2","p2","p1","p1","p2")
start_sec <- c(0,10.7,11.8,3.9,7.4,12.1,0,3.3,0)
dur_sec <- c(7.1,8.2,9.3,10.4,11.5,12.6,13.7,14.8,15.9)
df <- data.frame(group,person,start_sec,dur_sec)
df
在此先感谢您的所有评论和反馈!