Yes, Thanks!
-Lauri
2008/10/1 Dimitris Rizopoulos <[EMAIL PROTECTED]>
> one way is the following:
>
> 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))
>
> lapply(split(df, df$month), funct
> 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)
one way is the following:
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))
lapply(split(df, df$month), function(x) split(x, x$fac))
I hope it helps.
Best,
Dimitris
Lauri Nikkinen wrote
R users,
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
4 matches
Mail list logo