Skip to content
Prev 166123 / 398502 Next

Using apply for two datasets

Perhaps you can convert your matrices to data frames as in:

mapply(t.test,as.data.frame(myData1),as.data.frame(myData2))
to test by column and

mapply(t.test,as.data.frame(t(myData1)),as.data.frame(t(myData2)))


to test by row?


----- Original Message ----
From: Gang Chen <gangchen6 at gmail.com>
To: Henrique Dallazuanna <wwwhsd at gmail.com>
Cc: r-help at stat.math.ethz.ch
Sent: Tuesday, January 6, 2009 10:10:44 AM
Subject: Re: [R] Using apply for two datasets

Thanks a lot for the quick help!

mapply() seems promising. However, mapply(t.test, myData1, myData2)
would not work, so how can I specify the margin in mapply() which
function t.test() will be applied over? For example, I specify the 2nd
dimension (column) in apply(myData1, 2, t.test) to run one-sample
t-test. Is there a way I can achieve the same with mapply()?

Thanks again,
Gang
On Tue, Jan 6, 2009 at 12:34 PM, Henrique Dallazuanna <wwwhsd at gmail.com> wrote:
______________________________________________
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.