I just wasted a whole day searching for a solution for my problem.

So briefly, I have 2 datasets with 2 samples each from a wilcox_test. Now, I wanted to test for effect size. For the first dataset I receive an effect size "r", for the other I receive a error message:

library(rcompanion)
wilcoxonPairedR(x = sport_1_4$value, g = sport_1_4$variable)
Fehler in wilcoxonZ(x = x[as.numeric(g) == 1], y = x[as.numeric(g) == 2], :
'x' and 'y' must have the same length

Hi @rokochan95,
Welcome to the RStudio Community Forum.

The error message says that when your data is split into the two groups (based on the values in column sport_1_4$variable) those groups are NOT the same size; for a valid test they must be equal (and each in the correct matching order). So, the problem is in your data frame. You can check the group sizes as follows:

The last part is the problem, that's different from my first dataset sport_1_2.
The Question is why the don't have the same length, even though they have.

sport_1_2 and sport_1_4 really are they same except the different values for the variable sport_t4 in sport_1_4.

Hi @rokochan95,
The reason your earlier code was not working is that your grouping variable was a factor with 4 levels not 2 (despite 2 of the 4 having no observations), and only the first 2 are used by the function - hence the error. Your data frame needed to be modified to remove the 2 redundant levels. See help(droplevels)