R: split elements of a list into sublists
Use lapply
:
lapply(all.inc, function(x) split(x, x$pat))
If you'd like to split your data frame all at once, you could use
split(df, interaction(df$pat,df$inc))
However, the returned value will be a single list of data frames, which is slightly different from what you would get by splitting list elements.