Hi I have 2 sets of data that I want to do a Wilcoxon test on. They are of the same dimension. One has 4 zero values and the other has 5.> dim(SampA)[1] 1 10> dim(SampV)[1] 1 10 I get the folowing error Error in wilcox.test.default(SampA, SampV, na.rm = TRUE, paired = FALSE, : 'x' must be numeric I am using the function wilcox.test(SampA, SampV, na.rm=TRUE, paired=FALSE, conf.level=0.95)
What do you get with: str(SampA) str(SampV) The error message suggests you are not giving it numeric vectors. -- David Winsemius On Mar 2, 2009, at 10:59 AM, Amit Patel wrote:> Hi > I have 2 sets of data that I want to do a Wilcoxon test on. They are > of the same dimension. One has 4 zero values and the other has 5. >> dim(SampA) > [1] 1 10 >> dim(SampV) > [1] 1 10 > > I get the folowing error > > Error in wilcox.test.default(SampA, SampV, na.rm = TRUE, paired = > FALSE, : > 'x' must be numeric > > > > I am using the function > wilcox.test(SampA, SampV, na.rm=TRUE, paired=FALSE, conf.level=0.95) > > > > > > ______________________________________________ > 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.
Hi, type is(sampA) is(sampV) in the R-prompt. It will show you that at least one of the vectors is not a vector of numerical values in R's sense. Then you have to convert using the as.numeric() function, but you will have to make sure that this really gives you the original vectors. Since your vectors are only 1x10, it's probably easier to type them in anew. Cheers, Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von Amit Patel Gesendet: Monday, March 02, 2009 11:00 AM An: r-help at r-project.org Betreff: [R] Help with Wilcoxon Test Hi I have 2 sets of data that I want to do a Wilcoxon test on. They are of the same dimension. One has 4 zero values and the other has 5.> dim(SampA)[1] 1 10> dim(SampV)[1] 1 10 I get the folowing error Error in wilcox.test.default(SampA, SampV, na.rm = TRUE, paired = FALSE, : 'x' must be numeric I am using the function wilcox.test(SampA, SampV, na.rm=TRUE, paired=FALSE, conf.level=0.95) ______________________________________________ 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.
Amit Patel wrote:> Hi > I have 2 sets of data that I want to do a Wilcoxon test on. They are of the same dimension. One has 4 zero values and the other has 5. > >> dim(SampA) >> > [1] 1 10 > >> dim(SampV) >> > [1] 1 10 > > I get the folowing error > > Error in wilcox.test.default(SampA, SampV, na.rm = TRUE, paired = FALSE, : > 'x' must be numeric > > > > I am using the function > wilcox.test(SampA, SampV, na.rm=TRUE, paired=FALSE, conf.level=0.95) >Hi Amit, This is probably due to the fact that SampA is not numeric (SampB may be the same). When you say "zero values", I suspect you may mean NAs, and SampA and SampB are read in from a data file of some sort. It's quite common for users to assume that an empty field (or even a space or a period ".") will be read as NA. If this sounds like it may be the problem, check the function that you are using to read in the data for an na.strings argument, and see if it is what you think it is. If it isn't, any column of a resulting data frame will usually come in as a factor. Jim
Apparently Analagous Threads
- Help with t.test
- The three routines in R that calculate the wilcoxon signed-rank test give different p-values.......which is correct?
- exact Wilcoxon signed rank test with ties and the "no longer under development" exactRanksumTests package
- Wilcoxon signed rank test and its requirements
- wilcoxon-pratt signed rank test in R - drug-effiacy