try this:
dat <- data.frame(x = runif(100),
fac1 = rep(c("a", "b", "c", "d"), each = 25),
fac2 = rep(c("A", "B"), 50))
splits <- c("fac1", "fac2")
split(dat, dat[splits])
I hope it helps.
Best,
Dimitris
On 6/17/2011 2:34 PM, carslaw wrote:
Dear R-users
I seem to be stumped on some
Dear R-users
I seem to be stumped on something simple. I want to split a data frame
by factor levels given in one or more columns e.g. given
dat <- data.frame(x = runif(100),
fac1 = rep(c("a", "b", "c", "d"), each = 25),
fac2 = rep(c("A", "B"), 50))
I know
2 matches
Mail list logo