On Oct 16, 2008, at 8:11 AM, Jorge Ivan Velez wrote:
Dear John,
Yes. Assuming that 'sample2' is fixed, something like this should do
what
you want:
# Data sets
set.seed(123)
sample1=matrix(rnorm(100),ncol=10)
sample2=rnorm(10,5,4)
# t-test p-values
apply(X,1,function(x) t.test(x,sample2)$p.value)
It seems clear that you meant to type:
apply(sample1,1,function(x) t.test(x,sample2)$p.value)
[1] 0.002348970 0.004733230 0.004810952 0.004907549 0.002342979
0.018748229
0.003546655 0.006084410
[9] 0.003100983 0.007007980
HTH,
Jorge
On Thu, Oct 16, 2008 at 8:01 AM, John Sorkin <[EMAIL PROTECTED]
>wrote:
R 2.7.2
Windows XP
I am using apply to compute a series of Student's t-test from two
matrices,
sample1 and sample2.
boo<-apply(sample1,1,t.test,sample2)
I want to pick of the p-values from the tests, but can't seem to
get it to
work. I have tried several methods to get the values including:
boo<-apply(sample1,1,t.test$t.test,sample2)
boo<-apply(sample1,1,t.test,sample2)$t.test
any suggestions?
Thanks
John
John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence
University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
[EMAIL PROTECTED]
Confidentiality Statement:
This email message, including any attachments, is for ...{{dropped:
13}}
______________________________________________
R-help@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.
______________________________________________
R-help@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.