On 12.09.2011 13:16, Raphael Saldanha wrote:
Hi!
Try something like this:
subset(example, disease==TRUE)
subset(example, disease==FALSE)
Hmmm, I think the actual answer to the question is something along this
line:
sapply(example[names(example)!="disease"],
function(x) t.test(x ~ example[["disease"]])[[3]])
Uwe Ligges
On Mon, Sep 12, 2011 at 4:54 AM, C.H.<chainsawti...@gmail.com> wrote:
Dear R experts,
Suppose I have an data frame likes this:
example<- data.frame(age=c(1,2,3, 4,5,6),
height=c(100,110,120,130,140,150), disease=c(TRUE, TRUE, TRUE, FALSE, FALSE,
FALSE))
example
age height disease
1 1 100 TRUE
2 2 110 TRUE
3 3 120 TRUE
4 4 130 FALSE
5 5 140 FALSE
6 6 150 FALSE
Is there anyway to compare the age and height between those with
disease=TRUE and disease=FALSE using t.test and extract the p-values
quickly?
I can do this individually
t.test(example$age~example$disease)[3]
But when the number of variable grow to something like 200 it is not
easy any more.
Thanks!
Regards,
CH
--
CH Chan
______________________________________________
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.