Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

effectsize issue with wilcox.test when named the same as variable #592

Closed
rempsyc opened this issue Jul 3, 2023 · 2 comments
Closed

effectsize issue with wilcox.test when named the same as variable #592

rempsyc opened this issue Jul 3, 2023 · 2 comments

Comments

@rempsyc
Copy link
Member

rempsyc commented Jul 3, 2023

Maybe this is expected but it seems like the name of the object creates a conflict if it is the same as the variable (can close if expected).

x <- c(1.83,  0.50,  1.62,  2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)
z <- wilcox.test(x, y, paired = TRUE)

# Works
effectsize::effectsize(z)
#> r (rank biserial) |       95% CI
#> --------------------------------
#> 0.78              | [0.30, 0.94]

# Fails
x <- z
effectsize::effectsize(x)
#> Error: Unable to retrieve data from htest object.
#>   Try using 'rb()' directly.

Created on 2023-07-03 with reprex v2.0.2

@rempsyc rempsyc closed this as completed Jul 3, 2023
@rempsyc rempsyc reopened this Jul 3, 2023
@rempsyc rempsyc changed the title effectsize.wilcox.test seems broken now effectsize issue with wilcox.test when named the same as variable Jul 3, 2023
@mattansb
Copy link
Member

mattansb commented Jul 3, 2023

This is expected - insight::get_data() uses the names stored in the htest.

x <- c(1.83,  0.50,  1.62,  2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)
z <- wilcox.test(x, y, paired = TRUE)

insight::get_data(z)
#>        x y
#> 1  1.830 1
#> 2  0.500 1
#> 3  1.620 1
#> 4  2.480 1
#> 5  1.680 1
#> 6  1.880 1
#> 7  1.550 1
#> 8  3.060 1
#> 9  1.300 1
#> 10 0.878 2
#> 11 0.647 2
#> 12 0.598 2
#> 13 2.050 2
#> 14 1.060 2
#> 15 1.290 2
#> 16 1.060 2
#> 17 3.140 2
#> 18 1.290 2

x <- z
insight::get_data(z) # No longer works.
#> NULL
insight::get_data(x)
#> NULL

Created on 2023-07-03 with reprex v2.0.2

(Are you beginning to see that the htest class is 💩? Honestly, it's a miracle it works as good as it does...)

@mattansb mattansb closed this as completed Jul 3, 2023
@rempsyc
Copy link
Member Author

rempsyc commented Jul 3, 2023

Haha, thanks for clarifying this! Good reference for the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants