- 1. [S] avoid loop (score: 1)
- Author: Ren Yu <ryu@emmes.com>
- Date: Wed, 20 Sep 2000 13:43:46 -0400
- Hi all, I want to perform a 2-sample t-test for each row(m_i) of a dataframe(m x (n1+n2)). Is there a quick way without having loop to do it ? Since my data set usually has thousands of rows. Thanks
- /archives/html/s-news/2000-09/msg00147.html (6,803 bytes)
- 2. Re: [S] avoid loop (score: 1)
- Author: Prof Brian D Ripley <ripley@stats.ox.ac.uk>
- Date: Wed, 20 Sep 2000 20:17:40 +0100 (BST)
- Well, apply(A, 2, function(x) t.test(x[1:n1], x[(n1+1):n2])$p.value) avoids the loop, but why do you want to do this? I would apply this to blocks of say, 100 or 1000 rows at a time. if a loop is rea
- /archives/html/s-news/2000-09/msg00148.html (8,149 bytes)
- 3. [S] Avoid loop (score: 1)
- Author: Arisman Adnan <Arisman.Adnan@newcastle.ac.uk>
- Date: Tue, 2 Nov 1999 12:20:32 +0000 (GMT)
- Dear all, How can I avoid the loop when I need to calculate : aa <- a[i]+b1[j]+b2 a <- c(1,2) ; i=1:2 b1 <- c(1,2,3) ; j=1:3 b2 <-c(1,2,3,4) ; k=1:4 the result should be like this (in matrix) 1+1+(1,
- /archives/html/s-news/1999-11/msg00011.html (7,471 bytes)
- 4. Re: [S] Avoid loop (score: 1)
- Author: Prof Brian Ripley <ripley@stats.ox.ac.uk>
- Date: Tue, 2 Nov 1999 12:29:54 +0000 (GMT)
- z <- drop(as.matrix(expand.grid(a, b1))%*% rep(1,2)) outer(z, b2, "+") does what you want. You might like to look at the pieces to see why. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of App
- /archives/html/s-news/1999-11/msg00012.html (8,280 bytes)
- 5. Re: [S] Avoid loop (score: 1)
- Author: Arisman Adnan <Arisman.Adnan@newcastle.ac.uk>
- Date: Wed, 3 Nov 1999 09:25:26 +0000 (GMT)
- Thank you Prof Ripley. Nice solution! I've change it a bit into: expand.grid(b1, a). Regards, Aris,-- -- This message was distributed by s-news@wubios.wustl.edu. To unsubscribe send e-mail to s-news-
- /archives/html/s-news/1999-11/msg00026.html (7,681 bytes)
This search system is powered by
Namazu