It will never hurt your chances to get an answer if you tell what the code in
the different language actually does. Is it doing t-est for all of the
variables and the group indicators are in a separate column? If, imagine you
have the following data:
id<-rep(c(1,2),each=100)
x<-c(rnorm(100,0,1),rnorm(100,0.5,1))
y<-c(rnorm(100,-1,1),rnorm(100,-2,1))
z<-c(rnorm(100,3,1),rnorm(100,3.25,1))
data<-data.frame(id,x,y,z)
#Now run a t.test on each column of data that is not "id",
apply(data[,c("x","y","z")],2,function(a)
t.test(a[data$id==1],a[data$id==2]))
Here apply(data[,c("x","y","z")], ..., ...) says
to select the columns with
the names x, y, and z from the data.frame named data.
apply(... , 2, ...) tells to apply a function over the columns (rather than
rows) of the selected data
and apply(..., ... , function(a) t.test(a[data$id==1],a[data$id==2])) tells
to run the t.test on the input variable a (the input variable a will then be
x, y, and z, respectively) for the group ids as they are stored in data$id.
HTH,
Daniel
Mihovil Pletikos wrote:>
> hi
> i am new to r and i would like to how could i do something like this in
> spss:
>
> T-TEST GROUPS=who('1' '2')
> /MISSING=ANALYSIS
> /VARIABLES= X3881686 X2672712 X2842570 X3526544 X2902531 X2402942
> X3382216
> X3771800 X2427469 X2392945 X2453006 X2562821 X3416651 X3552083 X3721851
> X2477438 X2926969 X3026969 X3442176 X3796335 X2622772 X3636470 X2952497
> X2367537 X3332276 X2427500 X2647315
> /CRITERIA=CI(.95).
>
> so i wouldn't have to enter the name of columns by hand, but
automaticly
> ... please help me
>
> Mihovil
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
--
View this message in context:
http://r.789695.n4.nabble.com/simple-t-test-for-multiple-colimns-tp3802347p3804194.html
Sent from the R help mailing list archive at Nabble.com.