I am extracting specific rows from a list of data frames in R and would like to have those rows assembled into a new data frame. As an example, I will use the iris data:
data(iris)
a.iris <- split(iris, iris$Species)
b.iris <- lapply(a.iris, function(x) with(x, x[3,]))
I want the return from lapply()
to be arranged into a single data frame that is in the same structure as the original data frame (e.g., names(iris)
). I have been looking at the plyr package but cannot find the right code to make this work. Any assistance would be greatly appreciated!
Brian