I have a data frame with following structure:
pat <- c(rep(1,50), rep(2,50), rep(3,50))
inc <- rep(c(rep(1,5), rep(2,5), rep(3,5), rep(4,5), rep(5,5),
rep(6,5), rep(7,5), rep(8,5), rep(9,5), rep(10,5)), 3)
df <- data.frame(cbind(pat, inc))
df is split into a list of elements:
all.inc = split(df, inc)
Now I want to split each element of this list into sub-lists. Something like:
all.pat = split(all.inc, pat)
This doesn’t work, obviously. I’ve already tried the plyr functions and lapply, but didn’t get it to work.
Any ideas?
Use
lapply: