[R] how to use apply on a two variable t-test

Jonathan Baron baron at psych.upenn.edu
Wed Dec 31 16:30:50 CET 2003


On 12/31/03 09:12, Jason Dunsmore wrote:
>does anyone know how to use the apply function on a two-variable t-test?
>i've tried everything.

Suppose d1 and d2 are data frames, and you want to do a t test of
column 1 of d1 vs. column 1 of d2, column 2 of d1 vs. column 2 of
d2, and so on.  Then

mapply(t.test,d1,d2)

will do it.  It wasn't clear from your orignal statement what
form your data were in.  You have to put them in a data frame for
this approach to work.

Jon
-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page:            http://www.sas.upenn.edu/~baron
R page:               http://finzi.psych.upenn.edu/ [down right now]




More information about the R-help mailing list