Skip to content
Prev 57597 / 398498 Next

Questions of t.test {stats}

Dear colegue,

I am not sure if it is this what you want, but to apply the t.test to all
rows in a data frame, you can do like:

apply(dataframe, 1, t.test)

If you want to store the results in a nice data frame, to us after, then you
should do a function, for example:

#################################### wilcox CI plus median
median.ci.wilcox=function(y){
# print("example: use to construct graphs with 95% CI, using xYplot, from
Hmisc. use summarize to compute the CI in function of factors")
if (is.R()) {require(ctest)}
if(length(y)>5){
c=t.test(y, conf.int=T, conf.level=.95)
res=c(mean=c$estimate, Lower=c(c$conf.int[1]), Upper=c(c$conf.int[2]))}
else {res=c(median=NA, Lower=NA, Upper=NA)}
res
}



hope this helps,
All the best,
Marta


----- Original Message ----- 
From: "pcscan" <s938611 at mail.yzu.edu.tw>
To: <r-help at stat.math.ethz.ch>
Sent: Tuesday, October 19, 2004 4:04 AM
Subject: [R] Questions of t.test {stats}
row
all
these
============================================================================
c(-0.299611385,-0.164028986,-0.225545128,-0.244473171,-0.276619985,-0.276362
81,-0.289633015,-0.298994167,-0.27908886,-0.265612916,-0.262321082,-0.295753
768,-0.235677803,-0.283872306,-0.282174954,-0.241592817,-0.274716893,-0.2886
55752,-0.262166777,-0.263298345,-0.252239841,-0.298274078,-0.28958158,-0.187
174691,-0.26628157,-0.252034102,-0.248793703,-0.267207398,-0.289838754,-0.28
4283785,-0.118097619,-0.27898599,-0.265818655,-0.295085114,-0.246839177,-0.2
76105636,-0.293336328,-0.294210721,-0.259543597,0.18181929,-0.276311375,-0.2
48948008,-0.212583533,-0.247147786,-0.269573403,-0.27636281,-0.295445158,-0.
281146256,-0.27636281,-0.255840285,-0.292513369,-0.21664689,-0.228014003,-0.
238249548,-0.238300983,-0.238506723,-0.242004296,-0.213869405,-0.272916672,-
0.293233458,-0.239483986,-0.147672687,-0.289941624,-0.233774712,-0.237940939
,-0.276517115,-0.22431069,-0.217469848,0.461573717,-0.218858591,-0.280271863
,-0.290867452,-0.177144886,-0.179150847,-0.258463465,-0.269470533,-0.2482279
19,-0.221327466,-0.217418413,-0.290044494,-0.290610278,-0.260006512,-0.22261
3338,-0.275951331,0.015118775,0.116959879,-0.24509039,-0.092894518,0.5274618
c(0.963784092,-0.266641614,4.623274441,1.6857758,-0.251159709,-0.090631382,1
http://www.R-project.org/posting-guide.html