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

Factors don't always work as intended #292

Open
mattansb opened this issue Jul 9, 2023 · 0 comments
Open

Factors don't always work as intended #292

mattansb opened this issue Jul 9, 2023 · 0 comments
Labels
bug 🐛 Something isn't working

Comments

@mattansb
Copy link
Member

mattansb commented Jul 9, 2023

library(correlation)
#> Warning: package 'correlation' was built under R version 4.2.3

data("mtcars")

mtcars$cyl <- factor(mtcars$cyl)

correlation(mtcars, 
            select = c("mpg", "cyl"), 
            include_factors = TRUE)
#> # Correlation Matrix (pearson-method)
#> 
#> Parameter1 | Parameter2 |     r |         95% CI | t(30) |         p
#> --------------------------------------------------------------------
#> mpg        |      cyl.4 |  0.80 | [ 0.63,  0.90] |  7.35 | < .001***
#> mpg        |      cyl.6 | -0.03 | [-0.38,  0.32] | -0.17 | 0.866    
#> mpg        |      cyl.8 | -0.74 | [-0.87, -0.53] | -6.06 | < .001***
#> cyl.4      |      cyl.6 | -0.38 | [-0.65, -0.04] | -2.27 | 0.061    
#> cyl.4      |      cyl.8 | -0.64 | [-0.81, -0.37] | -4.54 | < .001***
#> cyl.6      |      cyl.8 | -0.47 | [-0.70, -0.14] | -2.89 | 0.021*   
#> 
#> p-value adjustment method: Holm (1979)
#> Observations: 32

Fails

correlation(mtcars, 
            select = c("mpg"), 
            select2 = c("cyl"), 
            include_factors = TRUE)
#> Warning: The table is empty, no rows left to print.
#> Can't export table to 
#>   text
#>   , data frame is empty.

cyl is in Parameter1 not in Parameter2:

correlation(mtcars, 
            select = c("mpg"), 
            select2 = c("cyl", "am"), 
            include_factors = TRUE)
#> # Correlation Matrix (pearson-method)
#> 
#> Parameter1 | Parameter2 |     r |         95% CI | t(30) |       p
#> ------------------------------------------------------------------
#> mpg        |         am |  0.60 | [ 0.32,  0.78] |  4.11 | 0.001**
#> cyl.4      |         am |  0.47 | [ 0.15,  0.71] |  2.94 | 0.019* 
#> cyl.6      |         am |  0.02 | [-0.33,  0.37] |  0.13 | 0.896  
#> cyl.8      |         am | -0.47 | [-0.71, -0.15] | -2.94 | 0.019* 
#> 
#> p-value adjustment method: Holm (1979)
#> Observations: 32

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

@mattansb mattansb added the bug 🐛 Something isn't working label Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant