Re: [R] t.test in for loop

2010-07-22 Thread Peter Ehlers
On 2010-07-22 11:28, Arne Schulz wrote: Dear list, I'd like to do several t-test within a for loop. Example follows: data1<- rnorm(1:25) data2<- rnorm(1:25) vars<- c("data1", "data2") for (i in vars) { t.test(i) } Unfortunately, it does not work because of the quotes in the vars

Re: [R] t.test in for loop

2010-07-22 Thread Henrique Dallazuanna
Try this: apply(Vectorize(get)(ls(patt = 'data')), 2, t.test) On Thu, Jul 22, 2010 at 2:28 PM, Arne Schulz < arne.sch...@student.uni-kassel.de> wrote: > Dear list, > I'd like to do several t-test within a for loop. Example follows: > > data1 <- rnorm(1:25) > data2 <- rnorm(1:25) > vars <- c("da

Re: [R] t.test in for loop

2010-07-22 Thread David Winsemius
On Jul 22, 2010, at 1:28 PM, Arne Schulz wrote: Dear list, I'd like to do several t-test within a for loop. Example follows: data1 <- rnorm(1:25) data2 <- rnorm(1:25) vars <- c("data1", "data2") for (i in vars) { t.test(i) } Unfortunately, it does not work because of the quote

[R] t.test in for loop

2010-07-22 Thread Arne Schulz
Dear list, I'd like to do several t-test within a for loop. Example follows: data1 <- rnorm(1:25) data2 <- rnorm(1:25) vars <- c("data1", "data2") for (i in vars) { t.test(i) } Unfortunately, it does not work because of the quotes in the vars-vector (running t.test(data1) by hand