I have data frame "df" following:
df=data.frame(time=as.factor(rep(c(0.01*(1:100)),each=49)),
roi=rep(1:49,100),
area=runif(4900, 5.0, 7.5),hours=(rep(1:10,each=490)))
The df is split into 10 smaller data frames based on column "hours"
x=split(df,df$hours)
In each sub-data frame one new data frame "br[i] is made following:
br1=data.frame(x$`1`[c(1,round(nrow(x$`1`)*(1:4)/4)),])
br1$Min=c(0,15,30,45,60)
br2=data.frame(x$`2`[c(1,round(nrow(x$`2`)*(1:4)/4)),])
br2$Min=c(0,15,30,45,60)
...
br10=data.frame(x$`10`[c(1,round(nrow(x$`10`)*(1:4)/4)),])
br10$Min=c(0,15,30,45,60)
The question is how to made 10 data frames "br" automatically without repeat such above commands in many time?
Thanks so much for any response!
lapply(x, function(x) x[c(1,round(nrow(x)*(1:4)/4)),])