Re: [R] Iteratively subsetting data by factor level across multiple variables

2015-01-15 Thread William Dunlap
There are lots of ways to do this. You have to decide on how you want to organize the results. Here are two ways that use only core R packages. Many people like the plyr package for this split-data/analyze-parts/combine-results sort of thing. > df <- data.frame(x=1:27,response=log2(1:27),

[R] Iteratively subsetting data by factor level across multiple variables

2015-01-15 Thread Reid Bryant
Hi R experts! I would like to have a scripted solution that will iteratively subset data across many variables per factor level of each variable. To illustrate, if I create a dataframe (df) by: variation <- c("A","B","C","D") element1 <- as.factor(c(0,1,0,1)) element2 <- as.factor(c(0,0,1,1)) re