Dear useRs, Thanks for any advices
# I do not know where are the examples how to mark groups # based on signal occurence in the additional variable: cf. variable c2, # How to calculate different calculations for groups defined by (split by occurence of c2 characteristic data) #First example of simple data #mexample 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 c0<-rbind( 1, 2 , 3, 4, 5, 6, 7, 8, 9,10,11, 12,13,14,15,16,17 ) c0 c1<-rbind(10, 20 ,30,40, 50,10,60,20,30,40,50, 30,10, 0,NA,20,10.3444) c1 c2<-rbind(NA,"Start1",NA,NA,"Stop1",NA,NA,NA,NA,NA,NA,"Start2",NA,NA,NA,NA,"Stop2") c2 C.df<-data.frame(cbind(c0,c1,c2)) colnames(C.df)<-c("c0","c1","c2") C.df # preparation of form for explaining further needed result (next 3 lines are not needed indeed, they are only to explain how to obtain final result c3<-rbind(NA,"Start1","Start1","Start1","Start1","Start2","Start2","Start2","Start2","Start2","Start2","Start2","Start2","Start2","Start2","Start2","Start2") c4<-rbind(NA, "Stop1", "Stop1", "Stop1", "Stop1", "Stop2", "Stop2", "Stop2", "Stop2", "Stop2", "Stop2", "Stop2", "Stop2", "Stop2", "Stop2", "Stop2", "Stop2") C.df<-data.frame(cbind(c0,c1,c2,c3,c4)) colnames(C.df)<-c("c0","c1","c2","c3","c4") C.df$c5<-paste(C.df$c3,C.df$c4,sep="-") C.df # NEEDED RESULTS # needed result # for Stat1-Stop1: mean(20,30,40,50) # for Stat2-Stop2: mean(c(10,60,20,30,40,50,30,10,0,NA,20,10.3444), na.rm=T) #mean: c1 c3 c4 c5 20 Start1 Stop1 Start1-Stop1 25.48585 Start2 Stop2 Start2-Stop2 #sum # for Stat1-Stop1: sum(20,30,40,50) # for Stat2-Stop2: sum(c(10,60,20,30,40,50,30,10,0,NA,20,10.3444), na.rm=T) #sum: c1 c3 c4 c5 140 Start1 Stop1 Start1-Stop1 280.3444 Start2 Stop2 Start2-Stop2 # for Stat1-Stop1: max(20,30,40,50) # for Stat2-Stop2: max(c(10,60,20,30,40,50,30,10,0,NA,20,10.3444), na.rm=T) #max: c1 c3 c4 c5 50 Start1 Stop1 Start1-Stop1 60 Start2 Stop2 Start2-Stop2 # place of max (in Start1-Stop1: 4 th element in gruop Start1-Stop1 # place of max (in Start1-Stop1: 2 nd element in gruop Start1-Stop1 c0 c3 c4 c5 4 Start1 Stop1 Start1-Stop1 2 Start2 Stop2 Start2-Stop2 Thanks for any suggestion, Kaluza [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.