[R] Help with Wilcoxon Test

Jim Lemon jim at bitwrit.com.au
Tue Mar 3 09:32:45 CET 2009


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




More information about the R-help mailing list