Dear R-helpers,

I have split a dataframe into a list with five elements, with the following
code:

> datalist<-split(data,data$UNIT)

I would now like to run some code (below) on each element of the list to
extract rows from the list elements; then I would like to rbind the
extracted rows into a new dataframe containing all of the extracted rows
from all of the list elements.

I don't need any help with the code itself, it works fine for one chunk of
data (e.g., a single dataframe). The code is:

t0<-match(times$START_DT, data$DATETIME) #MAKE A VECTOR OF START TIMES
t1<-match(times$STOP_DT, data$DATETIME) #MAKE A VECTOR OF STOP TIMES
indices<-mapply(FUN = ":", t0, t1) #MAKES A LIST, EACH ELEMENT CONTAINS
INDICES OF TIMES CORRESPONDING TO ONE WETLAND
idex<-times[rep(1:nrow(times), sapply(indices, length)),
c("POND_ID","OBS","REP","PID"), drop = FALSE] #MAKES A DATAFRAME
tm<-data[unlist(indices), ] #FLATTENS THE LIST OF INDICES INTO A DATAFRAME
extracted<-cbind(idex, tm) #BIND IDEX AND TM

But now that I've split my data into a list with five elements, what I don't
know how to do is wrap my code in a loop or function so I can run it on each
of the five list elements and then rbind the extracted rows together into a
new dataframe.

(What I have now is 5 replicates of the above code, and I would like to
replace that with a loop or function.)

I have spent all morning on this, without much progress, so would appreciate
any help you might be able to provide.

Thanks! Mark Na

	[[alternative HTML version deleted]]


