diff --git a/NEWS.md b/NEWS.md index db06c3710..8c8222fe4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,16 @@ # ggstatsplot 0.1.1.9000 -# + +MINOR + + - Minor code refactoring that gets rid of the following dependencies: + `magrittr`, `ellipsis`, `purrrlyr`. + +MAJOR + + - The *p*-value label now specifies whether the *p*-value displayed in + `ggbetweenstats` and `ggwithinstats` pairwise comparisons were adjusted or + not for multiple comparisons. + # ggstatsplot 0.1.1 ANNOUNCEMENTS diff --git a/R/ggbetweenstats.R b/R/ggbetweenstats.R index ce6f3dd43..62b3381d2 100644 --- a/R/ggbetweenstats.R +++ b/R/ggbetweenstats.R @@ -251,7 +251,7 @@ ggbetweenstats <- function(data, return = "plot", messages = TRUE) { - # no pairwise comparisons are available for bayesian t-tests + # no pairwise comparisons are available for Bayesian t-tests if (type %in% c("bf", "bayes") && isTRUE(pairwise.comparisons)) { pairwise.comparisons <- FALSE } diff --git a/R/ggcoefstats.R b/R/ggcoefstats.R index 52f70b9dd..56dbf2dbe 100644 --- a/R/ggcoefstats.R +++ b/R/ggcoefstats.R @@ -165,6 +165,7 @@ #' @importFrom tibble as_tibble rownames_to_column #' @importFrom tidyr unite #' @importFrom groupedstats lm_effsize_standardizer +#' @importFrom insight is_model #' #' @references #' \url{https://indrajeetpatil.github.io/ggstatsplot/articles/web_only/ggcoefstats.html} @@ -375,17 +376,6 @@ ggcoefstats <- function(x, # =================== list of objects (for tidy and glance) ================ - # dataframe objects - df.mods <- c( - "data.frame", - "data.table", - "grouped_df", - "tbl", - "tbl_df", - "spec_tbl_df", - "resampled_df" - ) - # creating a list of objects which will have fixed and random "effects" # only fixed effects will be selected mixed.mods <- @@ -432,108 +422,99 @@ ggcoefstats <- function(x, glance_df <- broomExtra::glance(x) # if the object is not a dataframe, check if summary caption is to be displayed - if (!class(x)[[1]] %in% df.mods) { + if (isTRUE(insight::is_model(x))) { # if glance is not available, inform the user - if (is.null(glance_df) && output == "plot") { + if (is.null(glance_df) || !all(c("logLik", "AIC", "BIC") %in% names(glance_df))) { + # inform the user message(cat( crayon::green("Note: "), - crayon::blue( - "No model diagnostics information available for the object of class", - crayon::yellow(class(x)[[1]]), - ".\n" - ), + crayon::blue("No model diagnostics information available, so skipping caption.\n"), sep = "" )) # and skip the caption caption.summary <- FALSE - } else { - # if glance is not null, but the needed metric are not available, skip caption - if (!all(c("logLik", "AIC", "BIC") %in% names(glance_df))) { - caption.summary <- FALSE - } } } # ============================= dataframe =============================== - if (class(x)[[1]] %in% df.mods) { + if (isFALSE(insight::is_model(x))) { # set tidy_df to entered dataframe tidy_df <- tibble::as_tibble(x) - # check that statistic is specified + # check that `statistic` is specified if (rlang::is_null(statistic)) { - message(cat( - crayon::red("Note"), - crayon::blue( - ": For the object of class", - crayon::yellow(class(x)[[1]]), - ", the argument `statistic` is not specified ('t', 'z', or 'f').\n", - "Statistical labels will therefore be skipped.\n" - ), - sep = "" - )) - # skip labels stats.labels <- FALSE - } - # =========================== broom.mixed tidiers ======================= - } else if (class(x)[[1]] %in% mixed.mods) { - # getting tidy output using `broom.mixed` - tidy_df <- - broomExtra::tidy( - x = x, - conf.int = conf.int, - # exponentiate = exponentiate, - conf.level = conf.level, - effects = "fixed", - scales = scales, - ... - ) - # ====================== tidying F-statistic objects =================== - } else if (class(x)[[1]] %in% f.mods) { - # creating dataframe - tidy_df <- - groupedstats::lm_effsize_standardizer( - object = x, - effsize = effsize, - partial = partial, - conf.level = conf.level, - nboot = nboot - ) %>% - dplyr::rename(.data = ., statistic = F.value) - - # renaming the `xlab` according to the estimate chosen - if (effsize == "eta") { - if (isTRUE(partial)) { - xlab <- "partial eta-squared" - } else { - xlab <- "eta-squared" + # inform the user + if (output == "plot") { + message(cat( + crayon::red("Note"), + crayon::blue(": For the object of class"), + crayon::yellow(class(x)[[1]]), + crayon::blue(", the argument `statistic` must be specified ('t', 'z', or 'f').\n"), + crayon::blue("Statistical labels will therefore be skipped.\n"), + sep = "" + )) } } + } - if (effsize == "omega") { + # =========================== broom.mixed tidiers ======================= + + if (isTRUE(insight::is_model(x))) { + if (class(x)[[1]] %in% mixed.mods) { + # getting tidy output using `broom.mixed` + tidy_df <- + broomExtra::tidy( + x = x, + conf.int = conf.int, + # exponentiate = exponentiate, + conf.level = conf.level, + effects = "fixed", + scales = scales, + ... + ) + + # ====================== tidying F-statistic objects =================== + } else if (class(x)[[1]] %in% f.mods) { + # creating dataframe + tidy_df <- + groupedstats::lm_effsize_standardizer( + object = x, + effsize = effsize, + partial = partial, + conf.level = conf.level, + nboot = nboot + ) %>% + dplyr::rename(.data = ., statistic = F.value) + + # prefix for effect size if (isTRUE(partial)) { - xlab <- "partial omega-squared" + effsize.prefix <- "partial" } else { - xlab <- "omega-squared" + effsize.prefix <- NULL } + + # renaming the `xlab` according to the estimate chosen + xlab <- paste(effsize.prefix, " ", effsize, "-squared", sep = "") + # ==================== tidying everything else =========================== + } else { + tidy_df <- + broomExtra::tidy( + x = x, + conf.int = conf.int, + conf.level = conf.level, + se.type = se.type, + by_class = by.class, + component = component, + # exponentiate = exponentiate, + parametric = TRUE, # relevant for `gam` objects + ... + ) } - # ==================== tidying everything else =========================== - } else { - tidy_df <- - broomExtra::tidy( - x = x, - conf.int = conf.int, - conf.level = conf.level, - se.type = se.type, - by_class = by.class, - component = component, - # exponentiate = exponentiate, - parametric = TRUE, # relevant for `gam` objects - ... - ) } # =================== tidy dataframe cleanup ================================ @@ -611,7 +592,7 @@ ggcoefstats <- function(x, # =================== p-value computation ================================== # p-values won't be computed by default for some of the models - if (!class(x)[[1]] %in% df.mods && !"p.value" %in% names(tidy_df)) { + if (isTRUE(insight::is_model(x)) && !"p.value" %in% names(tidy_df)) { # use `sjstats` S3 methods to add them to the tidy dataframe tryCatch( expr = tidy_df %<>% @@ -678,11 +659,7 @@ ggcoefstats <- function(x, } else { # add NAs so that only dots will be shown tidy_df %<>% - dplyr::mutate( - .data = ., - conf.low = NA_character_, - conf.high = NA_character_ - ) + dplyr::mutate(.data = ., conf.low = NA_character_, conf.high = NA_character_) # stop displaying whiskers conf.int <- FALSE @@ -690,11 +667,8 @@ ggcoefstats <- function(x, # inform the user that skipping labels for the same reason message(cat( crayon::green("Note: "), - crayon::blue( - "No confidence intervals available for regression coefficients from", - crayon::yellow(class(x)[[1]]), - "object, so skipping whiskers in the plot.\n" - ), + crayon::blue("No confidence intervals available for regression coefficients"), + crayon::blue("object, so skipping whiskers in the plot.\n"), sep = "" )) } @@ -758,7 +732,9 @@ ggcoefstats <- function(x, # adding a column with labels to be used with `ggrepel` if (isTRUE(stats.labels)) { # in case a dataframe was entered, `x` and `tidy_df` are going to be same - if (class(x)[[1]] %in% df.mods) x <- tidy_df + if (isFALSE(insight::is_model(x))) { + x <- tidy_df + } # adding a column with labels using custom function tidy_df %<>% @@ -777,14 +753,12 @@ ggcoefstats <- function(x, # check if meta-analysis is to be run if (isTRUE(meta.analytic.effect) && "std.error" %in% names(tidy_df)) { - if (dim(dplyr::filter(.data = tidy_df, is.na(std.error)))[[1]] > 0) { + if (dim(dplyr::filter(.data = tidy_df, is.na(std.error)))[[1]] > 0L) { # inform the user that skipping labels for the same reason message(cat( crayon::red("Error: "), - crayon::blue( - "At least one of the values in the `std.error` column is NA.\n", - "No meta-analysis will be carried out.\n" - ), + crayon::blue("At least one of the `std.error` column values is `NA`.\n"), + crayon::blue("No meta-analysis will be carried out.\n"), sep = "" )) @@ -837,35 +811,33 @@ ggcoefstats <- function(x, # caption containing model diagnostics if (isTRUE(caption.summary)) { # for dataframe objects - if (class(x)[[1]] %in% df.mods && isTRUE(meta.analytic.effect)) { + if (isFALSE(insight::is_model(x)) && isTRUE(meta.analytic.effect)) { caption <- caption.meta } # for non-dataframe objects - if (!class(x)[[1]] %in% df.mods) { - if (!is.na(glance_df$AIC[[1]])) { - # preparing caption with model diagnostics - caption <- - substitute( - atop(displaystyle(top.text), - expr = - paste( - "AIC = ", - AIC, - ", BIC = ", - BIC, - ", log-likelihood = ", - LL - ) - ), - env = list( - top.text = caption, - AIC = specify_decimal_p(x = glance_df$AIC[[1]], k = k.caption.summary), - BIC = specify_decimal_p(x = glance_df$BIC[[1]], k = k.caption.summary), - LL = specify_decimal_p(x = glance_df$logLik[[1]], k = k.caption.summary) - ) + if (isTRUE(insight::is_model(x)) && !is.na(glance_df$AIC[[1]])) { + # preparing caption with model diagnostics + caption <- + substitute( + atop(displaystyle(top.text), + expr = + paste( + "AIC = ", + AIC, + ", BIC = ", + BIC, + ", log-likelihood = ", + LL + ) + ), + env = list( + top.text = caption, + AIC = specify_decimal_p(x = glance_df$AIC[[1]], k = k.caption.summary), + BIC = specify_decimal_p(x = glance_df$BIC[[1]], k = k.caption.summary), + LL = specify_decimal_p(x = glance_df$logLik[[1]], k = k.caption.summary) ) - } + ) } } @@ -897,10 +869,7 @@ ggcoefstats <- function(x, if (output == "plot") { # setting up the basic architecture plot <- - ggplot2::ggplot( - data = tidy_df, - mapping = ggplot2::aes(x = estimate, y = factor(term)) - ) + ggplot2::ggplot(data = tidy_df, mapping = ggplot2::aes(x = estimate, y = term)) # if needed, adding the vertical line if (isTRUE(vline)) { diff --git a/R/grouped_ggbetweenstats.R b/R/grouped_ggbetweenstats.R index 4a9acecde..7546def82 100644 --- a/R/grouped_ggbetweenstats.R +++ b/R/grouped_ggbetweenstats.R @@ -49,7 +49,10 @@ #' y = rating, #' grouping.var = mpaa, #' results.subtitle = FALSE, -#' ggplot.component = ggplot2::scale_y_continuous(breaks = seq(1, 9, 1)), +#' ggplot.component = ggplot2::scale_y_continuous( +#' breaks = seq(1, 9, 1), +#' limits = (c(1, 9)) +#' ), #' messages = FALSE #' ) #' } diff --git a/R/grouped_gghistostats.R b/R/grouped_gghistostats.R index d2a312ab4..cdd8e76a4 100644 --- a/R/grouped_gghistostats.R +++ b/R/grouped_gghistostats.R @@ -3,7 +3,6 @@ #' @description Helper function for `ggstatsplot::gghistostats` to apply this #' function across multiple levels of a given factor and combining the #' resulting plots using `ggstatsplot::combine_plots`. -#' @author Indrajeet Patil, Chuck Powell #' #' @inheritParams gghistostats #' @inheritParams grouped_ggbetweenstats diff --git a/R/helpers_ggbetweenstats_graphics.R b/R/helpers_ggbetweenstats_graphics.R index 80b704c7a..bfb371bc8 100644 --- a/R/helpers_ggbetweenstats_graphics.R +++ b/R/helpers_ggbetweenstats_graphics.R @@ -365,11 +365,8 @@ ggsignif_adder <- function(plot, df_pairwise %<>% dplyr::arrange(.data = ., group1) # computing y coordinates for ggsignif bars - ggsignif_y_position <- - ggsignif_position_calculator( - x = data %>% dplyr::pull({{ x }}), - y = data %>% dplyr::pull({{ y }}) - ) + ggsignif_coords <- + ggsignif_xy(data %>% dplyr::pull({{ x }}), data %>% dplyr::pull({{ y }})) # adding ggsignif comparisons to the plot plot <- plot + @@ -379,7 +376,7 @@ ggsignif_adder <- function(plot, textsize = textsize, tip_length = 0.01, vjust = vjust, - y_position = ggsignif_y_position, + y_position = ggsignif_coords, annotations = df_pairwise$label, test = NULL, na.rm = TRUE, @@ -391,7 +388,7 @@ ggsignif_adder <- function(plot, return(plot) } -#' @name ggsignif_position_calculator +#' @name ggsignif_xy #' @importFrom utils combn #' #' @inheritParams ggbetweenstats @@ -399,11 +396,11 @@ ggsignif_adder <- function(plot, #' @keywords internal #' @noRd -ggsignif_position_calculator <- function(x, y) { +ggsignif_xy <- function(x, y) { # number of comparisons n_comparions <- length(utils::combn(x = unique(x), m = 2L, simplify = FALSE)) - # start position on y-axis for the ggsignif lines + # start position on `y`-axis for the `ggsignif` lines y_start <- max(y, na.rm = TRUE) * (1 + 0.025) # steps in which the y values need to increase diff --git a/README.md b/README.md index 1ec4c40da..64402d4b4 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [![CRAN\_Release\_Badge](http://www.r-pkg.org/badges/version-ago/ggstatsplot)](https://CRAN.R-project.org/package=ggstatsplot) | [![Travis Build Status](https://travis-ci.org/IndrajeetPatil/ggstatsplot.svg?branch=master)](https://travis-ci.org/IndrajeetPatil/ggstatsplot) | [![Daily downloads badge](https://cranlogs.r-pkg.org/badges/last-day/ggstatsplot?color=blue)](https://CRAN.R-project.org/package=ggstatsplot) | [![GitHub version](https://img.shields.io/badge/GitHub-0.1.1.9000-orange.svg?style=flat-square)](https://github.com/IndrajeetPatil/ggstatsplot/) | [![Website](https://img.shields.io/badge/website-ggstatsplot-orange.svg?colorB=E91E63)](https://indrajeetpatil.github.io/ggstatsplot/) | | [![CRAN Checks](https://cranchecks.info/badges/summary/ggstatsplot)](https://cran.r-project.org/web/checks/check_results_ggstatsplot.html) | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/IndrajeetPatil/ggstatsplot?branch=master&svg=true)](https://ci.appveyor.com/project/IndrajeetPatil/ggstatsplot) | [![Weekly downloads badge](https://cranlogs.r-pkg.org/badges/last-week/ggstatsplot?color=blue)](https://CRAN.R-project.org/package=ggstatsplot) | [![Forks](https://img.shields.io/badge/forks-73-blue.svg)](https://github.com/IndrajeetPatil/ggstatsplot/) | [![Rdoc](https://www.rdocumentation.org/badges/version/ggstatsplot)](https://www.rdocumentation.org/packages/ggstatsplot) | -| [![minimal R version](https://img.shields.io/badge/R%3E%3D-3.5.0-6666ff.svg)](https://cran.r-project.org/) | [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/) | [![Monthly downloads badge](https://cranlogs.r-pkg.org/badges/last-month/ggstatsplot?color=blue)](https://CRAN.R-project.org/package=ggstatsplot) | [![Github Issues](https://img.shields.io/badge/issues-16-red.svg)](https://github.com/IndrajeetPatil/ggstatsplot/issues) | [![vignettes](https://img.shields.io/badge/vignettes-0.1.1-orange.svg?colorB=FF5722)](https://CRAN.R-project.org/package=ggstatsplot/vignettes/) | +| [![minimal R version](https://img.shields.io/badge/R%3E%3D-3.5.0-6666ff.svg)](https://cran.r-project.org/) | [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/) | [![Monthly downloads badge](https://cranlogs.r-pkg.org/badges/last-month/ggstatsplot?color=blue)](https://CRAN.R-project.org/package=ggstatsplot) | [![Github Issues](https://img.shields.io/badge/issues-19-red.svg)](https://github.com/IndrajeetPatil/ggstatsplot/issues) | [![vignettes](https://img.shields.io/badge/vignettes-0.1.1-orange.svg?colorB=FF5722)](https://CRAN.R-project.org/package=ggstatsplot/vignettes/) | | [![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/IndrajeetPatil/ggstatsplot.svg)](https://github.com/IndrajeetPatil/ggstatsplot) | [![Coverage Status](https://coveralls.io/repos/github/IndrajeetPatil/ggstatsplot/badge.svg?branch=master)](https://coveralls.io/github/IndrajeetPatil/ggstatsplot?branch=master) | [![Total downloads badge](https://cranlogs.r-pkg.org/badges/grand-total/ggstatsplot?color=blue)](https://CRAN.R-project.org/package=ggstatsplot) | [![Github Stars](https://img.shields.io/github/stars/IndrajeetPatil/ggstatsplot.svg?style=social&label=Github)](https://github.com/IndrajeetPatil/ggstatsplot) | [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2074621.svg)](https://doi.org/10.5281/zenodo.2074621) | -| [![Licence](https://img.shields.io/badge/licence-GPL--3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html) | [![Codecov test coverage](https://codecov.io/gh/IndrajeetPatil/ggstatsplot/branch/master/graph/badge.svg)](https://codecov.io/gh/IndrajeetPatil/ggstatsplot?branch=master) | [![HitCount](http://hits.dwyl.io/IndrajeetPatil/ggstatsplot.svg)](http://hits.dwyl.io/IndrajeetPatil/ggstatsplot) | [![Last-changedate](https://img.shields.io/badge/last%20change-2019--09--12-yellowgreen.svg)](https://github.com/IndrajeetPatil/ggstatsplot/commits/master) | [![GitHub last commit](https://img.shields.io/github/last-commit/IndrajeetPatil/ggstatsplot.svg)](https://github.com/IndrajeetPatil/ggstatsplot/commits/master) | +| [![Licence](https://img.shields.io/badge/licence-GPL--3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html) | [![Codecov test coverage](https://codecov.io/gh/IndrajeetPatil/ggstatsplot/branch/master/graph/badge.svg)](https://codecov.io/gh/IndrajeetPatil/ggstatsplot?branch=master) | [![HitCount](http://hits.dwyl.io/IndrajeetPatil/ggstatsplot.svg)](http://hits.dwyl.io/IndrajeetPatil/ggstatsplot) | [![Last-changedate](https://img.shields.io/badge/last%20change-2019--09--16-yellowgreen.svg)](https://github.com/IndrajeetPatil/ggstatsplot/commits/master) | [![GitHub last commit](https://img.shields.io/github/last-commit/IndrajeetPatil/ggstatsplot.svg)](https://github.com/IndrajeetPatil/ggstatsplot/commits/master) | | [![status](https://tinyverse.netlify.com/badge/ggstatsplot)](https://CRAN.R-project.org/package=ggstatsplot) | [![Covrpage Summary](https://img.shields.io/badge/covrpage-Last_Build_2019_09_12-yellowgreen.svg)](https://github.com/IndrajeetPatil/ggstatsplot/blob/master/tests/README.md) | [![saythanks](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/IndrajeetPatil) | [![Project Status](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) | [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/IndrajeetPatil/ggstatsplot/issues) | | [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/ggstatsplot/community) | | | | | @@ -218,7 +218,7 @@ ggstatsplot::ggplot_converter #> function(plot) { #> cowplot::ggdraw() + cowplot::draw_grob(grid::grobTree(plot)) #> } -#> +#> #> ``` diff --git a/docs/articles/web_only/faq.html b/docs/articles/web_only/faq.html index 033aef8b2..5c421e9c0 100644 --- a/docs/articles/web_only/faq.html +++ b/docs/articles/web_only/faq.html @@ -141,7 +141,7 @@

Frequently asked questions

Indrajeet Patil

-

2019-09-15

+

2019-09-16

Source: vignettes/web_only/faq.Rmd @@ -184,7 +184,7 @@

# converting to plotly object plotly::ggplotly(p, width = 480, height = 480)
- +

@@ -249,12 +249,36 @@

# delete geom corresponding to points gginnards::delete_layers(x = p, match_type = "GeomPoint")

+

This can be helpful to add a new layer with aesthetic specifications of your liking.

+ +

Suggestions

-

If you find any bugs or have any suggestions/remarks, please file an issue on GitHub: https://github.com/IndrajeetPatil/ggstatsplot/issues

+

If you find any bugs or have any suggestions/remarks, please file an issue on GitHub: https://github.com/IndrajeetPatil/ggstatsplot/issues

diff --git a/docs/articles/web_only/faq_files/figure-html/gginnards-1.png b/docs/articles/web_only/faq_files/figure-html/gginnards-1.png index ac72c3e97..30886c161 100644 Binary files a/docs/articles/web_only/faq_files/figure-html/gginnards-1.png and b/docs/articles/web_only/faq_files/figure-html/gginnards-1.png differ diff --git a/docs/articles/web_only/faq_files/figure-html/gginnards2-1.png b/docs/articles/web_only/faq_files/figure-html/gginnards2-1.png new file mode 100644 index 000000000..bd08945e3 Binary files /dev/null and b/docs/articles/web_only/faq_files/figure-html/gginnards2-1.png differ diff --git a/docs/articles/web_only/ggcoefstats.html b/docs/articles/web_only/ggcoefstats.html index c9497aff1..a323c49ea 100644 --- a/docs/articles/web_only/ggcoefstats.html +++ b/docs/articles/web_only/ggcoefstats.html @@ -139,7 +139,7 @@

ggcoefstats

Indrajeet Patil

-

2019-09-15

+

2019-09-16

Source: vignettes/web_only/ggcoefstats.Rmd @@ -269,9 +269,10 @@

# plotting estimates ggstatsplot::ggcoefstats( x = car::Anova(mod, type = "III"), - title = "analysis of variance (`car` package)" -) -#> Note: No model diagnostics information available for the object of class anova .

+ title = "analysis of variance (`car` package)", + conf.level = 0.99 +) +#> Note: No model diagnostics information available, so skipping caption.

+ title = "robust estimation of linear mixed-effects model", + conf.level = 0.90 +) +#> Note: No model diagnostics information available, so skipping caption. +#> Note: No p-values and/or statistic available for regression coefficients from rlmerMod object; +#> skipping labels with stats.

+) +#> Note: No model diagnostics information available, so skipping caption.

+#> Note: No model diagnostics information available, so skipping caption.

+) +#> Note: No model diagnostics information available, so skipping caption.

+) +#> Note: No model diagnostics information available, so skipping caption.

+) +#> Note: No model diagnostics information available, so skipping caption.

+#> Note: No model diagnostics information available, so skipping caption.

As revealed by this analysis, all effects of this model are significant. But most of the variance is explained by the attribute, with the next important explanatory factor being the measure used. A very little amount of variation in measurement is accounted for by the interaction between these two factors.

@@ -1196,7 +1202,9 @@

labels = c("(a)", "(b)"), title.text = "Robust variants of `lmRob` and `glmRob` \n(from`robust` package)", nrow = 2 -) +) +#> Note: No model diagnostics information available, so skipping caption. +#> Note: No model diagnostics information available, so skipping caption.

+#> Note: No model diagnostics information available, so skipping caption. +#> Note: No model diagnostics information available, so skipping caption.

+) +#> Note: No model diagnostics information available, so skipping caption.

+) +#> Note: No model diagnostics information available, so skipping caption.

+#> Note: No model diagnostics information available, so skipping caption.

@@ -1521,8 +1532,9 @@

title = "bounded memory simple linear regression", exclude.intercept = FALSE ) -#> Note: No p-values and/or statistic available for regression coefficients from biglm object; -#> skipping labels with stats. +#> Note: No model diagnostics information available, so skipping caption. +#> Note: No p-values and/or statistic available for regression coefficients from biglm object; +#> skipping labels with stats.

+#> Note: No model diagnostics information available, so skipping caption. +#> Note: No p-values and/or statistic available for regression coefficients from bigglm object; +#> skipping labels with stats.

+) +#> Note: No model diagnostics information available, so skipping caption.

+) +#> Note: No model diagnostics information available, so skipping caption.

+#> Note: No model diagnostics information available, so skipping caption. +#> Note: No p-values and/or statistic available for regression coefficients from ridgelm object; +#> skipping labels with stats. +#> Note: No confidence intervals available for regression coefficientsobject, so skipping whiskers in the plot.

+) +#> Note: No model diagnostics information available, so skipping caption.

+) +#> Note: No model diagnostics information available, so skipping caption.

@@ -1944,8 +1962,9 @@

exclude.intercept = FALSE, title = "Model II regression" ) -#> Note: No p-values and/or statistic available for regression coefficients from lmodel2 object; -#> skipping labels with stats. +#> Note: No model diagnostics information available, so skipping caption. +#> Note: No p-values and/or statistic available for regression coefficients from lmodel2 object; +#> skipping labels with stats.

+) +#> Note: No model diagnostics information available, so skipping caption.

+#> Note: No confidence intervals available for regression coefficientsobject, so skipping whiskers in the plot.

@@ -2211,7 +2231,7 @@

title = "maximum likelihood estimation", ggtheme = ggthemes::theme_excel_new() ) -#> Note: No model diagnostics information available for the object of class mle2 . +#> Note: No model diagnostics information available, so skipping caption.

@@ -2269,7 +2289,8 @@

ggstatsplot::ggcoefstats( x = co, title = "Cochrane-Orcutt estimation" -) +) +#> Note: No model diagnostics information available, so skipping caption.

@@ -2345,7 +2366,8 @@

ggstatsplot::ggcoefstats( x = mod, title = "panel regression models fit \nvia multilevel modeling" -) +) +#> Note: No model diagnostics information available, so skipping caption.

@@ -2421,9 +2443,9 @@

#> Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling) #> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 9.694 seconds (Warm-up) -#> Chain 1: 4.981 seconds (Sampling) -#> Chain 1: 14.675 seconds (Total) +#> Chain 1: Elapsed Time: 8.472 seconds (Warm-up) +#> Chain 1: 4.701 seconds (Sampling) +#> Chain 1: 13.173 seconds (Total) #> Chain 1: #> #> SAMPLING FOR MODEL '7fc0444ee315785f19884bc3c9b2a5ab' NOW (CHAIN 2). @@ -2446,9 +2468,9 @@

#> Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling) #> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 2: -#> Chain 2: Elapsed Time: 20.004 seconds (Warm-up) -#> Chain 2: 47.877 seconds (Sampling) -#> Chain 2: 67.881 seconds (Total) +#> Chain 2: Elapsed Time: 18.788 seconds (Warm-up) +#> Chain 2: 42.886 seconds (Sampling) +#> Chain 2: 61.674 seconds (Total) #> Chain 2: #> #> SAMPLING FOR MODEL '7fc0444ee315785f19884bc3c9b2a5ab' NOW (CHAIN 3). @@ -2471,9 +2493,9 @@

#> Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling) #> Chain 3: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 3: -#> Chain 3: Elapsed Time: 6.91 seconds (Warm-up) -#> Chain 3: 5.257 seconds (Sampling) -#> Chain 3: 12.167 seconds (Total) +#> Chain 3: Elapsed Time: 6.7 seconds (Warm-up) +#> Chain 3: 4.417 seconds (Sampling) +#> Chain 3: 11.117 seconds (Total) #> Chain 3: #> #> SAMPLING FOR MODEL '7fc0444ee315785f19884bc3c9b2a5ab' NOW (CHAIN 4). @@ -2496,9 +2518,9 @@

#> Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling) #> Chain 4: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 4: -#> Chain 4: Elapsed Time: 6.534 seconds (Warm-up) -#> Chain 4: 4.742 seconds (Sampling) -#> Chain 4: 11.276 seconds (Total) +#> Chain 4: Elapsed Time: 5.833 seconds (Warm-up) +#> Chain 4: 4.964 seconds (Sampling) +#> Chain 4: 10.797 seconds (Total) #> Chain 4: # plot @@ -2509,8 +2531,9 @@

title = "Bayesian generalized (non-)linear \nmultivariate multilevel models", subtitle = "using `brms` package" ) -#> Note: No p-values and/or statistic available for regression coefficients from brmsfit object; -#> skipping labels with stats. +#> Note: No model diagnostics information available, so skipping caption. +#> Note: No p-values and/or statistic available for regression coefficients from brmsfit object; +#> skipping labels with stats.

+#> Note: No model diagnostics information available, so skipping caption. +#> Note: No p-values and/or statistic available for regression coefficients from stanreg object; +#> skipping labels with stats.

@@ -2605,7 +2629,7 @@

robust = TRUE, ess = TRUE ) -#> Note: No model diagnostics information available for the object of class mcmc . +#> Note: No model diagnostics information available, so skipping caption. #> Note: No p-values and/or statistic available for regression coefficients from mcmc object; #> skipping labels with stats.

@@ -2656,7 +2680,7 @@

title = "Markov Chain Monte Carlo with\nJust Another Gibbs Sampler", point.color = "darkgreen" ) -#> Note: No model diagnostics information available for the object of class rjags . +#> Note: No model diagnostics information available, so skipping caption. #> Note: No p-values and/or statistic available for regression coefficients from rjags object; #> skipping labels with stats.

@@ -2713,7 +2737,7 @@

labels = c("(a)", "(b)"), nrow = 1 ) -#> Note: No model diagnostics information available for the object of class gam . +#> Note: No model diagnostics information available, so skipping caption.

diff --git a/docs/articles/web_only/ggcoefstats_files/figure-html/anova1-1.png b/docs/articles/web_only/ggcoefstats_files/figure-html/anova1-1.png index 6b44cac1b..e9b43a214 100644 Binary files a/docs/articles/web_only/ggcoefstats_files/figure-html/anova1-1.png and b/docs/articles/web_only/ggcoefstats_files/figure-html/anova1-1.png differ diff --git a/docs/articles/web_only/ggcoefstats_files/figure-html/rlmer-1.png b/docs/articles/web_only/ggcoefstats_files/figure-html/rlmer-1.png index 634f3ae81..f998c0852 100644 Binary files a/docs/articles/web_only/ggcoefstats_files/figure-html/rlmer-1.png and b/docs/articles/web_only/ggcoefstats_files/figure-html/rlmer-1.png differ diff --git a/docs/news/index.html b/docs/news/index.html index 295c67a13..f3130915b 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -185,6 +185,14 @@

Changelog

ggstatsplot 0.1.1.9000 Unreleased

+

MINOR

+
    +
  • Minor code refactoring that gets rid of the following dependencies: magrittr, ellipsis, purrrlyr.
  • +
+

MAJOR

+
    +
  • The p-value label now specifies whether the p-value displayed in ggbetweenstats and ggwithinstats pairwise comparisons were adjusted or not for multiple comparisons.
  • +

diff --git a/docs/reference/figures/README-ggbetweenstats1-1.png b/docs/reference/figures/README-ggbetweenstats1-1.png index 48b1f868d..0ebecc2dc 100644 Binary files a/docs/reference/figures/README-ggbetweenstats1-1.png and b/docs/reference/figures/README-ggbetweenstats1-1.png differ diff --git a/docs/reference/figures/README-ggcoefstats1-1.png b/docs/reference/figures/README-ggcoefstats1-1.png index a2a1435c7..1bbf17098 100644 Binary files a/docs/reference/figures/README-ggcoefstats1-1.png and b/docs/reference/figures/README-ggcoefstats1-1.png differ diff --git a/docs/reference/figures/README-ggcorrmat1-1.png b/docs/reference/figures/README-ggcorrmat1-1.png index 59da9b144..eb5e0607c 100644 Binary files a/docs/reference/figures/README-ggcorrmat1-1.png and b/docs/reference/figures/README-ggcorrmat1-1.png differ diff --git a/docs/reference/figures/README-ggdotplotstats1-1.png b/docs/reference/figures/README-ggdotplotstats1-1.png index 4ebedfef1..f97c042a2 100644 Binary files a/docs/reference/figures/README-ggdotplotstats1-1.png and b/docs/reference/figures/README-ggdotplotstats1-1.png differ diff --git a/docs/reference/figures/README-gghistostats1-1.png b/docs/reference/figures/README-gghistostats1-1.png index 325c7698d..5cad20498 100644 Binary files a/docs/reference/figures/README-gghistostats1-1.png and b/docs/reference/figures/README-gghistostats1-1.png differ diff --git a/docs/reference/figures/README-ggpiestats1-1.png b/docs/reference/figures/README-ggpiestats1-1.png index e7f61e42a..113f793ea 100644 Binary files a/docs/reference/figures/README-ggpiestats1-1.png and b/docs/reference/figures/README-ggpiestats1-1.png differ diff --git a/docs/reference/figures/README-ggpiestats2-1.png b/docs/reference/figures/README-ggpiestats2-1.png index 4f7837afd..a301635b3 100644 Binary files a/docs/reference/figures/README-ggpiestats2-1.png and b/docs/reference/figures/README-ggpiestats2-1.png differ diff --git a/docs/reference/figures/README-ggpiestats3-1.png b/docs/reference/figures/README-ggpiestats3-1.png index c5a58f81b..e27b4e3ba 100644 Binary files a/docs/reference/figures/README-ggpiestats3-1.png and b/docs/reference/figures/README-ggpiestats3-1.png differ diff --git a/docs/reference/figures/README-ggscatterstats1-1.png b/docs/reference/figures/README-ggscatterstats1-1.png index 2bcff2036..772626995 100644 Binary files a/docs/reference/figures/README-ggscatterstats1-1.png and b/docs/reference/figures/README-ggscatterstats1-1.png differ diff --git a/docs/reference/figures/README-ggscatterstats3-1.png b/docs/reference/figures/README-ggscatterstats3-1.png index 57703fce1..19cae42c9 100644 Binary files a/docs/reference/figures/README-ggscatterstats3-1.png and b/docs/reference/figures/README-ggscatterstats3-1.png differ diff --git a/docs/reference/figures/README-ridgeplot-1.png b/docs/reference/figures/README-ridgeplot-1.png index 4d6aab6ee..c4719433b 100644 Binary files a/docs/reference/figures/README-ridgeplot-1.png and b/docs/reference/figures/README-ridgeplot-1.png differ diff --git a/docs/reference/grouped_ggbetweenstats-2.png b/docs/reference/grouped_ggbetweenstats-2.png index adc288535..63d5158c2 100644 Binary files a/docs/reference/grouped_ggbetweenstats-2.png and b/docs/reference/grouped_ggbetweenstats-2.png differ diff --git a/docs/reference/grouped_ggbetweenstats.html b/docs/reference/grouped_ggbetweenstats.html index c588eee4c..6b1d48b72 100644 --- a/docs/reference/grouped_ggbetweenstats.html +++ b/docs/reference/grouped_ggbetweenstats.html @@ -665,7 +665,10 @@

Examp y = rating, grouping.var = mpaa, results.subtitle = FALSE, - ggplot.component = ggplot2::scale_y_continuous(breaks = seq(1, 9, 1)), + ggplot.component = ggplot2::scale_y_continuous( + breaks = seq(1, 9, 1), + limits = (c(1, 9)) + ), messages = FALSE )

# } diff --git a/docs/reference/grouped_gghistostats.html b/docs/reference/grouped_gghistostats.html index d07407b09..0300aad2d 100644 --- a/docs/reference/grouped_gghistostats.html +++ b/docs/reference/grouped_gghistostats.html @@ -568,8 +568,6 @@

Contents

  • Examples
  • -

    Author

    -

    Indrajeet Patil, Chuck Powell

    diff --git a/man/figures/README-ggbetweenstats1-1.png b/man/figures/README-ggbetweenstats1-1.png index 48b1f868d..0ebecc2dc 100644 Binary files a/man/figures/README-ggbetweenstats1-1.png and b/man/figures/README-ggbetweenstats1-1.png differ diff --git a/man/figures/README-ggcoefstats1-1.png b/man/figures/README-ggcoefstats1-1.png index a2a1435c7..1bbf17098 100644 Binary files a/man/figures/README-ggcoefstats1-1.png and b/man/figures/README-ggcoefstats1-1.png differ diff --git a/man/figures/README-ggcorrmat1-1.png b/man/figures/README-ggcorrmat1-1.png index 59da9b144..eb5e0607c 100644 Binary files a/man/figures/README-ggcorrmat1-1.png and b/man/figures/README-ggcorrmat1-1.png differ diff --git a/man/figures/README-ggdotplotstats1-1.png b/man/figures/README-ggdotplotstats1-1.png index 4ebedfef1..f97c042a2 100644 Binary files a/man/figures/README-ggdotplotstats1-1.png and b/man/figures/README-ggdotplotstats1-1.png differ diff --git a/man/figures/README-gghistostats1-1.png b/man/figures/README-gghistostats1-1.png index 325c7698d..5cad20498 100644 Binary files a/man/figures/README-gghistostats1-1.png and b/man/figures/README-gghistostats1-1.png differ diff --git a/man/figures/README-ggpiestats1-1.png b/man/figures/README-ggpiestats1-1.png index e7f61e42a..113f793ea 100644 Binary files a/man/figures/README-ggpiestats1-1.png and b/man/figures/README-ggpiestats1-1.png differ diff --git a/man/figures/README-ggpiestats2-1.png b/man/figures/README-ggpiestats2-1.png index 4f7837afd..a301635b3 100644 Binary files a/man/figures/README-ggpiestats2-1.png and b/man/figures/README-ggpiestats2-1.png differ diff --git a/man/figures/README-ggpiestats3-1.png b/man/figures/README-ggpiestats3-1.png index c5a58f81b..e27b4e3ba 100644 Binary files a/man/figures/README-ggpiestats3-1.png and b/man/figures/README-ggpiestats3-1.png differ diff --git a/man/figures/README-ggscatterstats1-1.png b/man/figures/README-ggscatterstats1-1.png index 2bcff2036..772626995 100644 Binary files a/man/figures/README-ggscatterstats1-1.png and b/man/figures/README-ggscatterstats1-1.png differ diff --git a/man/figures/README-ggscatterstats3-1.png b/man/figures/README-ggscatterstats3-1.png index 57703fce1..19cae42c9 100644 Binary files a/man/figures/README-ggscatterstats3-1.png and b/man/figures/README-ggscatterstats3-1.png differ diff --git a/man/figures/README-ridgeplot-1.png b/man/figures/README-ridgeplot-1.png index 4d6aab6ee..c4719433b 100644 Binary files a/man/figures/README-ridgeplot-1.png and b/man/figures/README-ridgeplot-1.png differ diff --git a/man/grouped_ggbetweenstats.Rd b/man/grouped_ggbetweenstats.Rd index f6b03ab50..55f54ce10 100644 --- a/man/grouped_ggbetweenstats.Rd +++ b/man/grouped_ggbetweenstats.Rd @@ -354,7 +354,10 @@ ggstatsplot::grouped_ggbetweenstats( y = rating, grouping.var = mpaa, results.subtitle = FALSE, - ggplot.component = ggplot2::scale_y_continuous(breaks = seq(1, 9, 1)), + ggplot.component = ggplot2::scale_y_continuous( + breaks = seq(1, 9, 1), + limits = (c(1, 9)) + ), messages = FALSE ) } diff --git a/man/grouped_gghistostats.Rd b/man/grouped_gghistostats.Rd index c564f2943..4d9cbfe06 100644 --- a/man/grouped_gghistostats.Rd +++ b/man/grouped_gghistostats.Rd @@ -278,6 +278,3 @@ ggstatsplot::grouped_gghistostats( \code{\link{gghistostats}}, \code{\link{ggdotplotstats}}, \code{\link{grouped_ggdotplotstats}} } -\author{ -Indrajeet Patil, Chuck Powell -} diff --git a/tests/testthat/test-ggcoefstats.R b/tests/testthat/test-ggcoefstats.R index ddc030e8f..05ca93977 100644 --- a/tests/testthat/test-ggcoefstats.R +++ b/tests/testthat/test-ggcoefstats.R @@ -954,48 +954,51 @@ testthat::test_that( )) testthat::expect_identical(pb6$plot$labels$subtitle, meta_subtitle) - testthat::expect_identical(pb6$plot$labels$caption, ggplot2::expr(atop( - displaystyle(atop( - displaystyle(NULL), + testthat::expect_identical( + pb6$plot$labels$caption, + ggplot2::expr(atop( + displaystyle(atop( + displaystyle(NULL), + expr = paste( + "In favor of null: ", + "log"["e"], + "(BF"["01"], + ") = ", + "0.174", + ", ", + italic("d")["mean"]^"posterior", + " = ", + "0.110", + ", CI"["95%"], + " [", + "-0.178", + ", ", + "0.412", + "]" + ) + )), expr = paste( - "In favor of null: ", - "log"["e"], - "(BF"["01"], + "Heterogeneity: ", + italic("Q"), + "(", + "2", ") = ", - "0.174", + "6", + ", ", + italic("p"), + " = ", + "0.058", ", ", - italic("d")["mean"]^"posterior", + tau["REML"]^2, " = ", - "0.110", - ", CI"["95%"], - " [", - "-0.178", + "0.030", ", ", - "0.412", - "]" + "I"^2, + " = ", + "81.42%" ) - )), - expr = paste( - "Heterogeneity: ", - italic("Q"), - "(", - "2", - ") = ", - "6", - ", ", - italic("p"), - " = ", - "0.058", - ", ", - tau["REML"]^2, - " = ", - "0.030", - ", ", - "I"^2, - " = ", - "81.42%" - ) - ))) + )) + ) } ) @@ -1320,6 +1323,8 @@ testthat::test_that( desc = "unsupported model objects", code = { + # mod-1 + testthat::expect_error(ggstatsplot::ggcoefstats(x = list(x = "1", y = 2L))) # mod-2 mod2 <- stats::aov( diff --git a/vignettes/web_only/faq.Rmd b/vignettes/web_only/faq.Rmd index d7e2f6445..f5b13cd5f 100644 --- a/vignettes/web_only/faq.Rmd +++ b/vignettes/web_only/faq.Rmd @@ -21,6 +21,8 @@ knitr::opts_chunk$set( dpi = 300, out.width = "100%", collapse = TRUE, + message = FALSE, + warning = FALSE, comment = "#>" ) ``` @@ -122,7 +124,7 @@ remove them using `gginnards`. For example, let's say we want to remove the `geom_point()` from `ggbetweenstats` default plot. -```{r gginnards, message = FALSE, warning = FALSE, fig.width = 6, fig.height = 6} +```{r gginnards, message = FALSE, warning = FALSE, fig.width = 5, fig.height = 5} # needed libraries library(ggstatsplot) library(gginnards) @@ -140,10 +142,38 @@ p <- ggbetweenstats( gginnards::delete_layers(x = p, match_type = "GeomPoint") ``` +This can be helpful to add a new layer with aesthetic specifications of your +liking. + +```{r gginnards2, fig.width = 6, fig.height = 5} +set.seed(123) + +# needed libraries +library(ggstatsplot) +library(gginnards) +library(ggplot2) + +# basic plot without mean tagging +p <- + ggwithinstats( + data = bugs_long, + x = condition, + y = desire, + mean.plotting = FALSE, + messages = FALSE + ) + +# delete the geom_point layer +p <- gginnards::delete_layers(x = p, match_type = "GeomPoint") + +# add a new layers for points with a different `pch` +p + geom_point(shape = 23, aes(color = condition)) +``` + # Suggestions If you find any bugs or have any suggestions/remarks, please file an issue on -GitHub: +`GitHub`: # Session Information diff --git a/vignettes/web_only/ggcoefstats.Rmd b/vignettes/web_only/ggcoefstats.Rmd index d549477ab..2f4a63a99 100644 --- a/vignettes/web_only/ggcoefstats.Rmd +++ b/vignettes/web_only/ggcoefstats.Rmd @@ -20,7 +20,9 @@ vignette: > ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, - comment = "#>" + comment = "#>", + message = FALSE, + warning = FALSE ) ``` @@ -207,7 +209,8 @@ mod <- stats::lm( # plotting estimates ggstatsplot::ggcoefstats( x = car::Anova(mod, type = "III"), - title = "analysis of variance (`car` package)" + title = "analysis of variance (`car` package)", + conf.level = 0.99 ) ``` @@ -355,7 +358,8 @@ roblmm.mod <- robustlmm::rlmer( # plot ggstatsplot::ggcoefstats( x = roblmm.mod, - title = "robust estimation of linear mixed-effects model" + title = "robust estimation of linear mixed-effects model", + conf.level = 0.90 ) ```