I'm trying to carry out a Wilcox test in R but I am getting the following error:
> wilcox.test(vcrdp ~ vcrnodp, paired=F)
Error in wilcox.test.formula(vcrdp ~ vcrnodp, paired = F) :
grouping factor must have exactly 2 levels
The data comes from a CSV file with 2 numeric columns and the class in R is also numeric. When I check the levels for each variable I get this:
levels(vcrnodp)
NULL
Do I need to add levels to carry out the test? I've been searching for answers for a while and can't find anything that can help me so far.
Sample of data is:
Violent_crime_rate_dp Violent_crime_rate_nodp
1 32.262 23.067
2 7.838 15.469
3 75.560 10.918
4 198.029 58.888
5 22.802 61.087
6 25.593 12.665