[R] List of sublists

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Wed Oct 1 13:10:43 CEST 2008


> I would like to split this df by month and fac and produce list of 
sublists
> 
> df <- data.frame(month=as.character(rep(1:3,each=30)),
> fac=factor(rep(1:2,each=15)),
>             data1=round(runif(90),2),
>             data2=round(runif(90),2))
> 
> This
> 
> split(df, paste(df$month, df$fac))
> 
> produces just a single list. Any ideas?

Is this what you want?

lapply(split(df, df$month), split, df$fac)

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}



More information about the R-help mailing list