0

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

L Tyrone
  • 1,268
  • 3
  • 15
  • 24
Claire
  • 1
  • 1
  • I would start by checking if your predictor variable has 2 levels: length(levels(as.factor(my_data$`Payment Typology 1`))) – glagla Apr 27 '23 at 09:35

0 Answers0