Hi, Check out this function:- pairwise.wilcox.test {package=stats}. example(pairwise.wilcox.test)
On Fri, Oct 25, 2013 at 2:15 AM, Rui Barradas <ruipbarra...@sapo.pt> wrote: > Hello, > > There's a bug in your function, it should be 'dat', not 'dat1'. In the line > marked, below. > > fun1 <- function(dat){ > mat1 <- combn(colnames(dat),2) # Here, 'dat' not 'dat1' > > res <- sapply(seq_len(ncol(mat1)),function(i) {x1<- dat[,mat1[,i]]; > wilcox.test(x1[,1],x1[,2])$p.value}) > names(res) <- apply(mat1,2,paste,collapse="_") > res > } > > > Hope this helps, > > Rui Barradas > > Em 24-10-2013 20:16, arun escreveu: > >> Hi, >> Try: >> fun1 <- function(dat){ >> mat1 <- combn(colnames(dat1),2) >> res <- sapply(seq_len(ncol(mat1)),function(i) {x1<- dat[,mat1[,i]]; >> wilcox.test(x1[,1],x1[,2])$p.value}) >> names(res) <- apply(mat1,2,paste,collapse="_") >> res >> } >> >> set.seed(432) >> dat1 <- as.data.frame(matrix(sample(18*10,18*10,replace=FALSE),ncol=18)) >> >> fun1(dat1) #gives the p-value for each pair of columns >> >> >> >> >> Hi, >> >> I want to make a wilcoxon test, i have 18 columns each column >> corresponds to a different sample and i want to compare one to each >> other with a wilcoxon test in one step this is possible ? or do i >> compare two by tow? >> >> Does it exist a code for automation this test? like this i dont have to >> type the code for each couple. >> >> thanks! >> denisse >> >> ______________________________________________ >> 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. ______________________________________________ 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.