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

problems using group_by with cor.test report #424

Open
mihinduk opened this issue Apr 3, 2024 · 1 comment
Open

problems using group_by with cor.test report #424

mihinduk opened this issue Apr 3, 2024 · 1 comment

Comments

@mihinduk
Copy link

mihinduk commented Apr 3, 2024

Describe the bug
I am unable to use tidyverse group_by and then pass data to corr.test and generate a report.

Error in match.arg(alternative) :
'arg' must be NULL or a character vector

To Reproduce
Steps to reproduce the behaviour:
Here is the bug reproduced with the iris dataset:
iris %>%
group_by(Species) %>%
cor.test(iris$Sepal.Length, iris$Sepal.Width) %>%
report() %>%
as.data.frame()

Expected behaviour
Pearson's product-moment correlation

Parameter1 | Parameter2 | r | 95% CI | t(148) | p

iris$Sepal.Length | iris$Sepal.Width | -0.12 | [-0.27, 0.04] | -1.44 | 0.152

Alternative hypothesis: two.sided

BUT per Species

Screenshots

Screenshot 2024-04-03 at 1 09 49 PM

Specifications (please complete the following information):
packageVersion("rstatix")
[1] ‘0.7.2’
packageVersion("stats")
[1] ‘4.2.2’
packageVersion("easystats")
[1] ‘0.7.1’
packageVersion("report")
[1] ‘0.5.8’

@bwiernik
Copy link
Contributor

bwiernik commented Apr 3, 2024

cor.test() doesn't support grouped data frames. You would need to use a workflow that splits the data into separate frames by Species, such as with split() and lapply(). Or easier, use the correlation::correlation() function, which does support grouped data frames.

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