[R] wilcox test on two data frames

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Tue Nov 6 15:21:54 CET 2007


I don't think that the loop-part puts a great penalty in this case; 
however, it'd be better to convert the data.frames to matrices, since 
matrix indexing is faster, e.g.,

# I presume that you only want to keep the p-values
mat.A <- data.matrix(df.A)
mat.B <- data.matrix(df.B)
pvalues <- numeric(200)
for (i in 1:200) {
    pvalues[i] <- wilcox.test(x = mat.A[, i], y = mat.B[, i])$p.value
}


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Diogo Alagador" <alagador at oniduo.pt>
To: <r-help at r-project.org>
Sent: Tuesday, November 06, 2007 12:30 PM
Subject: [R] wilcox test on two data frames


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)

Thanks in advance,

Diogo André Alagador
Portugal

[[alternative HTML version deleted]]




--------------------------------------------------------------------------------


> ______________________________________________
> 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.
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list