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

cor_mat(): what's happened #68

Closed
maomaoworm2019 opened this issue Sep 24, 2020 · 1 comment
Closed

cor_mat(): what's happened #68

maomaoworm2019 opened this issue Sep 24, 2020 · 1 comment

Comments

@maomaoworm2019
Copy link

run codes:

diamonds %>%
mutate(across(where(is.factor), as.numeric)) %>%
cor_mat()

results:

A tibble: 10 x 11

rowname carat cut color clarity depth table price x y z


  • 1 carat 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97
    2 cut 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97
    3 color 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97
    4 clarity 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97
    5 depth 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97
    6 table 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97
    7 price 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97
    8 x 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97
    9 y 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97
    10 z 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97

Would you guys please help me find the bugs?

@kassambara
Copy link
Owner

Bug fixed in the cor_test() function, where there was a tidy evaluation conflict when the input data contains "x" and "y" as column names.

it works now:

suppressPackageStartupMessages(library(rstatix))
suppressPackageStartupMessages(library(dplyr))
data("diamonds", package = "ggplot2")
diamonds %>%
  mutate(across(where(is.factor), as.numeric)) %>%
  cor_mat()
#> # A tibble: 10 x 11
#>    rowname  carat    cut  color clarity  depth  table  price      x      y
#>  * <chr>    <dbl>  <dbl>  <dbl>   <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>
#>  1 carat    1     -0.13   0.290  -0.35   0.028  0.18   0.92   0.98   0.95 
#>  2 cut     -0.13   1     -0.021   0.19  -0.22  -0.43  -0.053 -0.13  -0.12 
#>  3 color    0.290 -0.021  1       0.026  0.047  0.026  0.17   0.27   0.26 
#>  4 clarity -0.35   0.19   0.026   1     -0.067 -0.16  -0.15  -0.37  -0.36 
#>  5 depth    0.028 -0.22   0.047  -0.067  1     -0.3   -0.011 -0.025 -0.029
#>  6 table    0.18  -0.43   0.026  -0.16  -0.3    1      0.13   0.2    0.18 
#>  7 price    0.92  -0.053  0.17   -0.15  -0.011  0.13   1      0.88   0.87 
#>  8 x        0.98  -0.13   0.27   -0.37  -0.025  0.2    0.88   1      0.97 
#>  9 y        0.95  -0.12   0.26   -0.36  -0.029  0.18   0.87   0.97   1    
#> 10 z        0.95  -0.15   0.27   -0.37   0.095  0.15   0.86   0.97   0.95 
#> # … with 1 more variable: z <dbl>

Created on 2021-02-14 by the reprex package (v0.3.0.9001)

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