[R] wilcox test on two data frames

Thomas Lumley tlumley at u.washington.edu
Tue Nov 6 15:46:33 CET 2007

On Tue, 6 Nov 2007, Diogo Alagador wrote:

> Hi all,
> Basically I have 2 data frames with equal dimension and I want to apply 
> the wilcox.test to compare columns in the same position (i.e. 1st of 
> df.A with 1st of df.B, 2nd of df.A with 2nd of df.B,...). Anyone give me 
> an hint on this, as I think it is nicer to avoid loops, specially for 
> huge dataframes (30000 x 200)

Avoiding loops is unlikely to help with speed. It is more likely to be 
useful to avoid large dataframes (using lists or matrices) but you may 
need the dataframe structure for something else.

If you really want to avoid loops because it is nicer you could use 
   mapply(wilcox.test, df.A, df.B)
but this might be slower than a loop.


More information about the R-help mailing list