1

Currently trying to run a grouped wilcox.test on relative humidity (erh) and temperature (temp) data. The dataframe looks like this:

head(sw_1d_wilcox_data, n = 25)

# A tibble: 25 x 3
  sens_type   erh     temp
    <chr> <dbl>    <dbl>
 1        OS  32.4 19.60000
 2        OS  32.4 19.52727
 3        OS  32.4 19.50000
 4        OS  32.4 19.50000
 5        OS  32.4 19.50000
 6        OS  32.4 19.50000 (...) # chopped it here for simplicity.

The variable "sens_type" is sensor type, and either DE or OS. I want to run a paired wilcox.test on both the "erh" and "temp" variables, grouped by sensor (i.e. OS against DE). My goal is to see if the sensors are different in terms of their measurements. It is paired data, as the sensors were in the same experimental container. My understanding of how to do this is:

wilcox.test(erh ~ sens_type, data = sw_1d_wilcox_data, paired = TRUE)

but I get the error:

Error in wilcox.test.default(x = c(97.4624454975128, 97.4624454975128, 
: 'x' and 'y' must have the same length

All variables are in correct classes (temp and erh = numeric, sens_type = character).

I've looked high and low, cannot find a post directly addressing this issue. Any help is greatly appreciated!

** a bonus would be some tag suggestions - I can't find a wilcoxon/wilcox tag or appropriate error tag (unclear to me how to use the existing ones).

Claire Lepine
  • 21
  • 2
  • 4

1 Answers1

2

If it's truly a paired test, then each sample should be of equal size. However, changing the paired argument in the wilcox.test function to 'FALSE' will enable you to run the test.

Ben Kronk
  • 33
  • 8