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

enable plot for correlation matrix #65

Closed
DominiqueMakowski opened this issue Mar 24, 2020 · 5 comments
Closed

enable plot for correlation matrix #65

DominiqueMakowski opened this issue Mar 24, 2020 · 5 comments

Comments

@DominiqueMakowski
Copy link
Member

plot(as.table(correlation(iris))) #Works
plot(as.matrix(correlation(iris))) # Doens't

image

We could have the same heatmap but only the lower-left triangular

Also, we could rename the legend title (here .data$r) by the column name (r, rho etc.)

@strengejacke
Copy link
Member

Also, we could rename the legend title (here .data$r) by the column name (r, rho etc.)

Should be in general r now, but where do we have different column names?

@DominiqueMakowski
Copy link
Member Author

  • You're right, it's always "r" in the summary even for correlation::correlation(iris, method="spearman")) where the column is rho
  • For the plot of as.matrix, as it doesn't return a specific class, yeah it's not possible to plot it for now. Although in theory, it would be easy to make it work and detect it, if no column named Parameter, then add such column using the row names and then run the same plot as the other, but I'm not sure what a good class name good be.
  • I noticed that for the triangular plot, we show only the upper triangular but the colnames, instead of being on the top such as in the printed output, are here on the bottom. Should we prioritize readability and plot the lower triangular, or consistency and leave it as is?
library(see)
print(summary(correlation::correlation(iris)))
#> Parameter    | Petal.Width | Petal.Length | Sepal.Width
#> -------------------------------------------------------
#> Sepal.Length |     0.82*** |      0.87*** |       -0.12
#> Sepal.Width  |    -0.37*** |     -0.43*** |            
#> Petal.Length |     0.96*** |              |
plot(summary(correlation::correlation(iris)))

Created on 2020-04-15 by the reprex package (v0.3.0)

@strengejacke
Copy link
Member

I noticed that for the triangular plot

Didn't even know it worked for triangular plots :-D

@strengejacke
Copy link
Member

strengejacke commented Apr 15, 2020

I'd say as.table() should save the name (rho, r) as attribute.

@strengejacke
Copy link
Member

strengejacke commented Apr 16, 2020

x <- summary(correlation::correlation(iris), redundant = TRUE)
x
#> Parameter    | Sepal.Length | Sepal.Width | Petal.Length | Petal.Width
#> ----------------------------------------------------------------------
#> Sepal.Length |      1.00*** |       -0.12 |      0.87*** |     0.82***
#> Sepal.Width  |        -0.12 |     1.00*** |     -0.43*** |    -0.37***
#> Petal.Length |      0.87*** |    -0.43*** |      1.00*** |     0.96***
#> Petal.Width  |      0.82*** |    -0.37*** |      0.96*** |     1.00***
plot(x, show_values = TRUE, show_p = TRUE)

x <- summary(correlation::correlation(iris), redundant = FALSE)
x
#> Parameter    | Petal.Width | Petal.Length | Sepal.Width
#> -------------------------------------------------------
#> Sepal.Length |     0.82*** |      0.87*** |       -0.12
#> Sepal.Width  |    -0.37*** |     -0.43*** |            
#> Petal.Length |     0.96*** |              |
plot(x, show_values = TRUE, show_p = TRUE)

x <- summary(correlation::correlation(iris, method = "spearman"))
plot(x)

Created on 2020-04-16 by the reprex package (v0.3.0)

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