[R] help needed

gauravbhatti gaurav15984 at hotmail.com
Sun Nov 23 19:31:16 CET 2008


Thankyou for the quick reply 
p <- array( 0, dim =c(5,100))  
porig <- array( 0, dim =c(5,1))
x1 <- array( rnorm(990,mean=0,sd=1), dim =c(4,10)) 

x <- rbind(c(1,1.5,1.4,3,1.9,4,4.9,2.6,3.2,2.4),x1)
i = 1; j=1;
for ( i in (1:5) )
{
 xorig1 = x[1,(1:5)];
 xorig2 = x[1,(6:10)];
 yorig = t.test(x1,x2,var.equal=TRUE);
 porig[i,1] = yo[[1]];
 for ( j in (1:100))
 {
  z = array( sample(x), dim =c(5,10))
 x1 = z[1,(1:5)];
 x2 = z[1,(6:10)];
 y = t.test(x1,x2,var.equal=TRUE);
 p[i,j] = y[[1]];
 
 j = j + 1;
 }
 i = i + 1;

}

This is the code i have been able to write so far. In this case i calculate
the t values for each row initiallay and then store it in porg matrix.In
order to randomize the matrix, I use sample(x) where x is the vector
containing all elements of the matrix. I create a new matrix of same
dimensions with the ranmdomized data and then perform t tests on each row
and store t values in p. this is done 100 times.
Please comment if you think there is better way.


gauravbhatti wrote:
> 
> hi I have a matrix (10x10) and I have to perform t tests on each row by
> considering first 5 elements as data set A and next 5 as data set B. This
> part is easy, However after one t test on each row, I have to randomly
> permute each column to get new values for each row and then perform
> another t.test. I can permute the column randomly using the function
> sample(x) but i am having problem in fitting this into the matrix to
> perform t test on the row. I would appreciate if someone can help me with
> this. 
> Or is there a function to randomly get different  matrix from one original
> matrix  without having to deal with different columns?
> 

-- 
View this message in context: http://www.nabble.com/help-needed-tp20648304p20649213.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list