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

ggtheme also accepts objects of 'theme' type #11

Merged
merged 1 commit into from Aug 29, 2018
Merged

ggtheme also accepts objects of 'theme' type #11

merged 1 commit into from Aug 29, 2018

Conversation

IndrajeetPatil
Copy link
Contributor

Minor changes

  1. Documentation roxygenized with the new version of roxygen2.
  2. All code styled with the tidyverse guidelines using styler package.

Major changes
The function now works with ggtheme argument of either function or theme type.

Example

library(ggcorrplot)
#> Loading required package: ggplot2

# Compute a correlation matrix
data(mtcars)
corr <- round(cor(mtcars), 1)
corr
#>       mpg  cyl disp   hp drat   wt qsec   vs   am gear carb
#> mpg   1.0 -0.9 -0.8 -0.8  0.7 -0.9  0.4  0.7  0.6  0.5 -0.6
#> cyl  -0.9  1.0  0.9  0.8 -0.7  0.8 -0.6 -0.8 -0.5 -0.5  0.5
#> disp -0.8  0.9  1.0  0.8 -0.7  0.9 -0.4 -0.7 -0.6 -0.6  0.4
#> hp   -0.8  0.8  0.8  1.0 -0.4  0.7 -0.7 -0.7 -0.2 -0.1  0.7
#> drat  0.7 -0.7 -0.7 -0.4  1.0 -0.7  0.1  0.4  0.7  0.7 -0.1
#> wt   -0.9  0.8  0.9  0.7 -0.7  1.0 -0.2 -0.6 -0.7 -0.6  0.4
#> qsec  0.4 -0.6 -0.4 -0.7  0.1 -0.2  1.0  0.7 -0.2 -0.2 -0.7
#> vs    0.7 -0.8 -0.7 -0.7  0.4 -0.6  0.7  1.0  0.2  0.2 -0.6
#> am    0.6 -0.5 -0.6 -0.2  0.7 -0.7 -0.2  0.2  1.0  0.8  0.1
#> gear  0.5 -0.5 -0.6 -0.1  0.7 -0.6 -0.2  0.2  0.8  1.0  0.3
#> carb -0.6  0.5  0.4  0.7 -0.1  0.4 -0.7 -0.6  0.1  0.3  1.0

# Compute a matrix of correlation p-values
p.mat <- cor_pmat(mtcars)
p.mat
#>               mpg          cyl         disp           hp         drat
#> mpg  0.000000e+00 6.112687e-10 9.380327e-10 1.787835e-07 1.776240e-05
#> cyl  6.112687e-10 0.000000e+00 1.802838e-12 3.477861e-09 8.244636e-06
#> disp 9.380327e-10 1.802838e-12 0.000000e+00 7.142679e-08 5.282022e-06
#> hp   1.787835e-07 3.477861e-09 7.142679e-08 0.000000e+00 9.988772e-03
#> drat 1.776240e-05 8.244636e-06 5.282022e-06 9.988772e-03 0.000000e+00
#> wt   1.293959e-10 1.217567e-07 1.222320e-11 4.145827e-05 4.784260e-06
#> qsec 1.708199e-02 3.660533e-04 1.314404e-02 5.766253e-06 6.195826e-01
#> vs   3.415937e-05 1.843018e-08 5.235012e-06 2.940896e-06 1.167553e-02
#> am   2.850207e-04 2.151207e-03 3.662114e-04 1.798309e-01 4.726790e-06
#> gear 5.400948e-03 4.173297e-03 9.635921e-04 4.930119e-01 8.360110e-06
#> carb 1.084446e-03 1.942340e-03 2.526789e-02 7.827810e-07 6.211834e-01
#>                wt         qsec           vs           am         gear
#> mpg  1.293959e-10 1.708199e-02 3.415937e-05 2.850207e-04 5.400948e-03
#> cyl  1.217567e-07 3.660533e-04 1.843018e-08 2.151207e-03 4.173297e-03
#> disp 1.222320e-11 1.314404e-02 5.235012e-06 3.662114e-04 9.635921e-04
#> hp   4.145827e-05 5.766253e-06 2.940896e-06 1.798309e-01 4.930119e-01
#> drat 4.784260e-06 6.195826e-01 1.167553e-02 4.726790e-06 8.360110e-06
#> wt   0.000000e+00 3.388683e-01 9.798492e-04 1.125440e-05 4.586601e-04
#> qsec 3.388683e-01 0.000000e+00 1.029669e-06 2.056621e-01 2.425344e-01
#> vs   9.798492e-04 1.029669e-06 0.000000e+00 3.570439e-01 2.579439e-01
#> am   1.125440e-05 2.056621e-01 3.570439e-01 0.000000e+00 5.834043e-08
#> gear 4.586601e-04 2.425344e-01 2.579439e-01 5.834043e-08 0.000000e+00
#> carb 1.463861e-02 4.536949e-05 6.670496e-04 7.544526e-01 1.290291e-01
#>              carb
#> mpg  1.084446e-03
#> cyl  1.942340e-03
#> disp 2.526789e-02
#> hp   7.827810e-07
#> drat 6.211834e-01
#> wt   1.463861e-02
#> qsec 4.536949e-05
#> vs   6.670496e-04
#> am   7.544526e-01
#> gear 1.290291e-01
#> carb 0.000000e+00

# with ggtheme of type `function`
ggcorrplot(corr, method = "circle", ggtheme = ggplot2::theme_bw)

# with ggtheme of type `theme`
ggcorrplot(corr, method = "circle", ggtheme = ggplot2::theme_dark())

Created on 2018-08-28 by the reprex package (v0.2.0.9000).

Rationale

This was done to make it compatible with my function ggstatsplot::ggcorrmat (https://github.com/IndrajeetPatil/ggstatsplot/blob/master/R/ggcorrmat.R), which is a wrapper around ggcorrplot. All functions in my package have the argument ggtheme, but I force users to enter a theme and not a function class object. So, out of the need for consistency across functions in a single package, I also wanted ggcorrmat to behave the same way, which is possible only if the underlying function (ggcorrplot::ggcorrplot) was modified.

@kassambara
Copy link
Owner

thank you for your contribution!!

@kassambara kassambara merged commit fa044d8 into kassambara:master Aug 29, 2018
@IndrajeetPatil
Copy link
Contributor Author

@kassambara Thanks for merging! Do you have any plans to push the current development version to CRAN any time soon?

@kassambara
Copy link
Owner

The plan is to submit it next week...

kassambara added a commit that referenced this pull request Aug 30, 2018
@IndrajeetPatil
Copy link
Contributor Author

Hi @kassambara

I am guessing you couldn't submit the package to CRAN because they had stopped accepting submission during holidays. They are accepting submissions again. Do you plan to submit the next release this week?

Trying to plan next release for my package accordingly.

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

Successfully merging this pull request may close these issues.

None yet

2 participants