I have a data.frame with ~250 observations (rows) in each of ~50
categories (columns). I would like to perform t.tests on subsets of
observations within each column, with the subsets according to index
vectors contained in other columns of the data.frame.
My data.frame looks something
Try this:
lapply(split(x, x$site),
function(.x){
.xl - split(.x[-(1:2)], .x$status)
mapply(t.test, .xl[[1]], .xl[[2]], SIMPLIFY = FALSE)
})
On Sat, Aug 21, 2010 at 11:15 AM, Alison Macalady a...@kmhome.org wrote:
I have a data.frame with ~250 observations (rows) in each of ~50 categories
Hi:
Henrique's solution is elegant, but if you want to summarize certain
features of the test (e.g., the value of the test statistic and its
p-value), then here's a different approach using packages reshape and plyr.
# Since your data in group C had a sample size of 2, I redid the data frame
3 matches
Mail list logo