The test/data: I am trying to run a wilcox_test on a large data set (over 22,000 rows). The test is type of insurance (9 options - remain in text form in my data set) vs. mortality risk (ordinal - minor, moderate, major, extreme - converted to 1,2,3,4 respectively.
I used the following code:
#import data
my_data <- read_excel(file.choose("C8_Health_Care_by_the_Numbers.xlsx"))
#wilcox test
my_data$`APR Risk of Mortality.f`= factor(my_data$`APR Risk of Mortality`, ordered = TRUE)
wilcox.test(`APR Risk of Mortality.f`~`Payment Typology 1`, data=my_data)
but I receive the following error:
Error in wilcox.test.formula('APR Risk of Mortality.f' ~ 'Payment Typology 1', : grouping factor must have exactly 2 levels