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-tp20648304p20648304.html Sent from the R help mailing list archive at Nabble.com.
would you post reproducible code with dummy data so that we have something to start with. thanks On Sun, Nov 23, 2008 at 12:08 PM, gauravbhatti <gaurav15984 at hotmail.com> 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-tp20648304p20648304.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
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.
I need some help in comparing t values avalaible from two data frames. I have two data frames with each containing a column for t valuse For example one data frame looks like as follows ID logFC t P.Value adj.P.Val B 39 a39 -1.737037118 -2.861784118 0.004212637 0.3120295 -2.504407 1 a1 -1.660000000 -2.734864780 0.006240591 0.3120295 -2.729203 53 a53 1.443725119 2.378549988 0.017380880 0.4517324 -3.305806 52 a52 -1.323602459 -2.180646836 0.029209548 0.4517324 -3.591351 14 a14 -1.288769209 -2.123258747 0.033732176 0.4517324 -3.669516 58 a58 1.286212422 2.119046418 0.034086544 0.4517324 -3.675172 75 a75 -1.268523811 -2.089904273 0.036626400 0.4517324 -3.713989 I have another one like it but the order of the ID column is different as shown below ID logFC t P.Value adj.P.Val B 76 a1 0.157096693 -0.258818201 0.795775514 0.9146845 -5.075035 63 a53 -0.146205781 -0.240875326 0.809651746 0.9200588 -5.077872 88 a58 0.108707988 0.179097379 0.857861240 0.9638890 -5.086083 23 a52 -0.086871304 -0.143121247 0.886194425 0.9757266 -5.089752 98 a53 0.085552023 0.140947720 0.887911243 0.9757266 -5.089947 90 a14 0.068456451 0.112782613 0.910202903 0.9868965 -5.092209 91 a75 -0.052087970 -0.085815394 0.931613169 0.9868965 -5.093904 I have to plot the t values obtained for each id against each other. Since the order of the IDs in the two data frames is different , I am finding it difficult to plot the t values. Can anyone help in arranging the t values in the increasing order of the ID values like 1 a1 .............. 2 a2 .................. 2 a3 .................. Thank you -- View this message in context: http://www.nabble.com/help-needed-tp20849087p20849087.html Sent from the R help mailing list archive at Nabble.com.
gauravbhatti wrote:> ... > I have to plot the t values obtained for each id against each other. Since > the order of the IDs in the two data frames is different , I am finding it > difficult to plot the t values. Can anyone help in arranging the t values in > the increasing order of the ID values like > 1 a1 .............. > 2 a2 .................. > 2 a3 .................. >Hi gauravbhatti, Try this (assuming your data frame is named "gvb"): gvb[order(as.character(gvb[,1])),] Jim