这个问题有几个部分:
答案 0 :(得分:0)
考虑到我不知道你的"事件"是的,我这个例子的事件是数据等于10
#Example Data
Row<-(1:20)
Data<-(1:20)
Df<-data.frame(Rows,Data)
#Sub Data based on conditon =10
subdata <- Df[apply(Df[,1:2] == 10, 1, all),]
#Find Row where event happened
OrginPoint<-subdata[1,1]
#Set ranges bsed on event
LowRange<-OrginPoint-5
HighRange<-OrginPoint+4
#Subset Data -5 rows for orign and +4 rows from orgin
DataRange1<-Df[LowRange:HighRange,1:2]