[R] darcs patch: Apply on data frame

Mr rong chen rongchen47 at yahoo.com
Thu Feb 17 08:15:28 CET 2011


Hi,



I am using a very simple R function to get each row from the
attached file and run Wilcox.test between columns 1-3 and 4-12. However, I keep
getting an error message. The data files is attached. Any suggestion?


Thank you.
Rong
Error message: 


+   return c$p.value

Error: unexpected symbol in:

"  c <- wilcox.test(a[g1], a[g2])

  return c"

Execution halted
Scrip:ranksum <- function(a){
  g1 <- c(1, 2, 3)
  g2 <- c(4, 5, 6, 7, 8, 9, 10, 11, 12)
  c <- wilcox.test(a[g1], a[g2])
  return c$p.value
}

data1 <- data.frame()
data1 <- read.table("test.txt", sep="\t", header=T)
p <- apply(data1, 1, ranksum)
write.table(p, file="test_p.out")


      
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110216/b58808a4/attachment.txt>


More information about the R-help mailing list