You can certainly use apply()
#make up some data
x <- 10; y <- 10; g <- 5
set.seed(1969)
dat <- matrix(rnorm((x + y) * g), ncol = x + y)
# apply() the t.test function to each row fo the matrix and extract
just the p value
results <- apply(dat, 1, function(dat) {
t.test(x = dat[1:x], y = d
Hi,
the actual thread on "multiple assignments ?" made up an interesting point for
me.
If I have a matrix with g rows and x + y columns where columns 1 - x contain
values of group1 and columns x+1 to y contain the values of group2.
Now I want to compute a vector of length g that holds the p-valu
2 matches
Mail list logo