[R] newbie question: p.values in a column

Bartz, Kevin Kevin.Bartz at FMR.COM
Wed Sep 18 16:10:21 CEST 2002


Why not specify a function in your apply statement?

v[,7] <- apply(v, 1, function(row) t.test(row)[3]$p.value)

Good luck.

Kevin

-----Original Message-----
From: Hao Chen [mailto:hchen at utmem.edu] 
Sent: Wednesday, September 18, 2002 8:48 AM
To: r-help at stat.math.ethz.ch
Subject: [R] newbie question: p.values in a column


Hello,

I have a vector (v) with 6 columns and 2000 rows. I am trying to do one 
sample t.test for each row (I know this sounds crazy) and put the 
p.values into the 7th column.

I know I can access the p.value via t.test(v[i,])[3]$p.value; I know I 
can do t.test on the row by apply(v, 1, t.test), but I just couldn't 
figure out how to fit them together.

I'd very appreciate your help!!

Hao Chen



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list