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-value (e.g. via a 
t-test) calculated for the appropriate row in the matrix.

At the moment I am doing something like this:
# code might be wrong. Should just give the idea.
p = rep(-1, g)
for( i in 1: g)
p[i] = t.test(values[i, c(1:x)], values[i, c(x +1: x+y)]

I am now wondering if there is a faster (maybe also more elegant) way to do 
this, e.g. using something like lapply or such?

Best,

Cedric

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to