From: stephen sefick <ssefick_at_gmail.com>

Date: Sun, 23 Nov 2008 22:02:14 -0500

Date: Sun, 23 Nov 2008 22:02:14 -0500

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)

#this randomizes each column

apply(x, MARGIN=2, FUN=sample)

I will try and think about it more, but I am not a great programer. What is it exactly that you want to do?

On Sun, Nov 23, 2008 at 1:31 PM, gauravbhatti <gaurav15984_at_hotmail.com> wrote:

*>
*

> 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.
**>
**> ______________________________________________
**> R-help_at_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.
**>
*

-- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis ______________________________________________ R-help_at_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.Received on Mon 24 Nov 2008 - 03:06:55 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Mon 24 Nov 2008 - 03:30:33 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*