Skip to content

Commit

Permalink
Merge branch 'main' into fail-on-lints
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil authored May 25, 2024
2 parents 61606cf + 5617a05 commit 5886278
Show file tree
Hide file tree
Showing 23 changed files with 564 additions and 594 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected].0
uses: JamesIves/[email protected].1
with:
branch: gh-pages
folder: docs
2 changes: 1 addition & 1 deletion API
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ggbetweenstats(data, x, y, type = "parametric", pairwise.display = "significant"
ggcoefstats(x, statistic = NULL, conf.int = TRUE, conf.level = 0.95, digits = 2L, exclude.intercept = FALSE, effectsize.type = "eta", meta.analytic.effect = FALSE, meta.type = "parametric", bf.message = TRUE, sort = "none", xlab = NULL, ylab = NULL, title = NULL, subtitle = NULL, caption = NULL, only.significant = FALSE, point.args = list(size = 3, color = "blue", na.rm = TRUE), errorbar.args = list(height = 0, na.rm = TRUE), vline = TRUE, vline.args = list(linewidth = 1, linetype = "dashed"), stats.labels = TRUE, stats.label.color = NULL, stats.label.args = list(size = 3, direction = "y", min.segment.length = 0, na.rm = TRUE), package = "RColorBrewer", palette = "Dark2", ggtheme = ggstatsplot::theme_ggstatsplot(), ...)
ggcorrmat(data, cor.vars = NULL, cor.vars.names = NULL, matrix.type = "upper", type = "parametric", tr = 0.2, partial = FALSE, digits = 2L, sig.level = 0.05, conf.level = 0.95, bf.prior = 0.707, p.adjust.method = "holm", pch = "cross", ggcorrplot.args = list(method = "square", outline.color = "black", pch.cex = 14), package = "RColorBrewer", palette = "Dark2", colors = c("#E69F00", "white", "#009E73"), ggtheme = ggstatsplot::theme_ggstatsplot(), ggplot.component = NULL, title = NULL, subtitle = NULL, caption = NULL, ...)
ggdotplotstats(data, x, y, xlab = NULL, ylab = NULL, title = NULL, subtitle = NULL, caption = NULL, type = "parametric", test.value = 0, bf.prior = 0.707, bf.message = TRUE, effsize.type = "g", conf.level = 0.95, tr = 0.2, digits = 2L, results.subtitle = TRUE, point.args = list(color = "black", size = 3, shape = 16), centrality.plotting = TRUE, centrality.type = type, centrality.line.args = list(color = "blue", linewidth = 1, linetype = "dashed"), ggplot.component = NULL, ggtheme = ggstatsplot::theme_ggstatsplot(), ...)
gghistostats(data, x, binwidth = NULL, xlab = NULL, title = NULL, subtitle = NULL, caption = NULL, type = "parametric", test.value = 0, bf.prior = 0.707, bf.message = TRUE, effsize.type = "g", conf.level = 0.95, tr = 0.2, digits = 2L, ggtheme = ggstatsplot::theme_ggstatsplot(), results.subtitle = TRUE, bin.args = list(color = "black", fill = "grey50", alpha = 0.7), centrality.plotting = TRUE, centrality.type = type, centrality.line.args = list(color = "blue", linewidth = 1, linetype = "dashed"), normal.curve = FALSE, normal.curve.args = list(linewidth = 2), ggplot.component = NULL, ...)
gghistostats(data, x, binwidth = NULL, xlab = NULL, title = NULL, subtitle = NULL, caption = NULL, type = "parametric", test.value = 0, bf.prior = 0.707, bf.message = TRUE, effsize.type = "g", conf.level = 0.95, tr = 0.2, digits = 2L, ggtheme = ggstatsplot::theme_ggstatsplot(), results.subtitle = TRUE, bin.args = list(color = "black", fill = "grey50", alpha = 0.7), centrality.plotting = TRUE, centrality.type = type, centrality.line.args = list(color = "blue", linewidth = 1, linetype = "dashed"), ggplot.component = NULL, ...)
ggpiestats(data, x, y = NULL, counts = NULL, type = "parametric", paired = FALSE, results.subtitle = TRUE, label = "percentage", label.args = list(direction = "both"), label.repel = FALSE, digits = 2L, proportion.test = results.subtitle, digits.perc = 0L, bf.message = TRUE, ratio = NULL, conf.level = 0.95, sampling.plan = "indepMulti", fixed.margin = "rows", prior.concentration = 1, title = NULL, subtitle = NULL, caption = NULL, legend.title = NULL, ggtheme = ggstatsplot::theme_ggstatsplot(), package = "RColorBrewer", palette = "Dark2", ggplot.component = NULL, ...)
ggscatterstats(data, x, y, type = "parametric", conf.level = 0.95, bf.prior = 0.707, bf.message = TRUE, tr = 0.2, digits = 2L, results.subtitle = TRUE, label.var = NULL, label.expression = NULL, marginal = TRUE, point.args = list(size = 3, alpha = 0.4, stroke = 0), point.width.jitter = 0, point.height.jitter = 0, point.label.args = list(size = 3, max.overlaps = 1e+06), smooth.line.args = list(linewidth = 1.5, color = "blue", method = "lm", formula = y ~ x), xsidehistogram.args = list(fill = "#009E73", color = "black", na.rm = TRUE), ysidehistogram.args = list(fill = "#D55E00", color = "black", na.rm = TRUE), xlab = NULL, ylab = NULL, title = NULL, subtitle = NULL, caption = NULL, ggtheme = ggstatsplot::theme_ggstatsplot(), ggplot.component = NULL, ...)
ggwithinstats(data, x, y, type = "parametric", pairwise.display = "significant", p.adjust.method = "holm", effsize.type = "unbiased", bf.prior = 0.707, bf.message = TRUE, results.subtitle = TRUE, xlab = NULL, ylab = NULL, caption = NULL, title = NULL, subtitle = NULL, digits = 2L, conf.level = 0.95, nboot = 100L, tr = 0.2, centrality.plotting = TRUE, centrality.type = type, centrality.point.args = list(size = 5, color = "darkred"), centrality.label.args = list(size = 3, nudge_x = 0.4, segment.linetype = 4), centrality.path = TRUE, centrality.path.args = list(linewidth = 1, color = "red", alpha = 0.5), point.args = list(size = 3, alpha = 0.5, na.rm = TRUE), point.path = TRUE, point.path.args = list(alpha = 0.5, linetype = "dashed"), boxplot.args = list(width = 0.2, alpha = 0.5, na.rm = TRUE), violin.args = list(width = 0.5, alpha = 0.2, na.rm = TRUE), ggsignif.args = list(textsize = 3, tip_length = 0.01, na.rm = TRUE), ggtheme = ggstatsplot::theme_ggstatsplot(), package = "RColorBrewer", palette = "Dark2", ggplot.component = NULL, ...)
Expand Down
2 changes: 0 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ Suggests:
vdiffr (>= 1.0.7),
withr,
WRS2
Remotes:
tidyverse/ggplot2
VignetteBuilder:
knitr
Encoding: UTF-8
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ N.B. All statistical analysis in `{ggstatsplot}` is carried out in
read the `NEWS` for that package:
<https://indrajeetpatil.github.io/statsExpressions/news/index.html>

## MAJOR CHANGES

- The feature to superimpose normality curve on a histogram (in `gghistostats()`) has been removed.
This feature always felt like an ad hoc addition to the plot, and has nothing to do with the key
statistical analysis in question (which is not about checking the normality of the distribution).

## BUG FIXES

- Empty groups in factors are no longer dropped in `ggpiestats()` and `ggbarstats()` (#935).
Expand Down
2 changes: 1 addition & 1 deletion R/ggdotplotstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @section Summary of graphics:
#'
#' ```{r child="man/rmd-fragments/gghistostats_graphics.Rmd"}
#' ```{r child="man/rmd-fragments/ggdotplotstats_graphics.Rmd"}
#' ```
#'
#' @param ... Currently ignored.
Expand Down
17 changes: 0 additions & 17 deletions R/gghistostats.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
#' ```
#'
#' @param ... Currently ignored.
#' @param normal.curve A logical value that decides whether to super-impose a
#' normal curve using `stats::dnorm(mean(x), stats::sd(x))`. Default is `FALSE`.
#' @param normal.curve.args A list of additional aesthetic arguments to be
#' passed to the normal curve.
#' @param binwidth The width of the histogram bins. Can be specified as a
#' numeric value, or a function that calculates width from `x`. The default is
#' to use the `max(x) - min(x) / sqrt(N)`. You should always check this value
Expand Down Expand Up @@ -80,8 +76,6 @@ gghistostats <- function(
centrality.plotting = TRUE,
centrality.type = type,
centrality.line.args = list(color = "blue", linewidth = 1, linetype = "dashed"),
normal.curve = FALSE,
normal.curve.args = list(linewidth = 2),
ggplot.component = NULL,
...) {
# data -----------------------------------
Expand Down Expand Up @@ -134,17 +128,6 @@ gghistostats <- function(
) +
guides(fill = "none")

# if normal curve overlay needs to be displayed
if (normal.curve) {
plot_hist <- plot_hist +
exec(
stat_function,
fun = function(x, mean, sd, n, bw) stats::dnorm(x, mean, sd) * n * bw,
args = list(mean = mean(x_vec), sd = stats::sd(x_vec), n = length(x_vec), bw = binwidth %||% .binwidth(x_vec)),
!!!normal.curve.args
)
}

# centrality plotting -------------------------------------

if (isTRUE(centrality.plotting)) {
Expand Down
6 changes: 3 additions & 3 deletions R/ggscatterstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#'
#' @description
#'
#' Scatterplots from `{ggplot2}` combined with marginal densigram (density +
#' histogram) plots with statistical details.
#' Scatterplots from `{ggplot2}` combined with marginal distributions plots
#' with statistical details.
#'
#' @section Summary of graphics:
#'
#' ```{r child="man/rmd-fragments/gghistostats_graphics.Rmd"}
#' ```{r child="man/rmd-fragments/ggscatterstats_graphics.Rmd"}
#' ```
#'
#' @param ... Currently ignored.
Expand Down
2 changes: 0 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@ grouped_gghistostats(
type = "nonparametric",
xlab = "Movies budget (in million US$)",
grouping.var = genre,
normal.curve = TRUE,
normal.curve.args = list(color = "red", size = 1),
ggtheme = ggthemes::theme_tufte(),
## modify the defaults from `{ggstatsplot}` for each plot
plotgrid.args = list(nrow = 1),
Expand Down
66 changes: 35 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

## `{ggstatsplot}`: `{ggplot2}` Based Plots with Statistical Details

| Status | Usage | Miscellaneous |
|---------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Status | Usage | Miscellaneous |
|----|----|----|
| [![R build status](https://github.com/IndrajeetPatil/ggstatsplot/workflows/R-CMD-check/badge.svg)](https://github.com/IndrajeetPatil/ggstatsplot) | [![Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/ggstatsplot?color=blue)](https://CRAN.R-project.org/package=ggstatsplot) | [![codecov](https://codecov.io/gh/IndrajeetPatil/ggstatsplot/branch/main/graph/badge.svg?token=ddrxwt0bj8)](https://app.codecov.io/gh/IndrajeetPatil/ggstatsplot) |
| [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html) | [![Daily downloads](https://cranlogs.r-pkg.org/badges/last-day/ggstatsplot?color=blue)](https://CRAN.R-project.org/package=ggstatsplot) | [![DOI](https://joss.theoj.org/papers/10.21105/joss.03167/status.svg)](https://doi.org/10.21105/joss.03167) |
| [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html) | [![Daily downloads](https://cranlogs.r-pkg.org/badges/last-day/ggstatsplot?color=blue)](https://CRAN.R-project.org/package=ggstatsplot) | [![DOI](https://joss.theoj.org/papers/10.21105/joss.03167/status.svg)](https://doi.org/10.21105/joss.03167) |

## Raison d’être <img src="man/figures/logo.png" align="right" width="360" />

Expand All @@ -27,10 +27,10 @@ makes data exploration simpler and faster.

## Installation

| Type | Source | Command |
|-------------|--------------------------------------------------------------------------------------------------------------------|------------------------------------------|
| Release | [![CRAN Status](https://www.r-pkg.org/badges/version/ggstatsplot)](https://cran.r-project.org/package=ggstatsplot) | `install.packages("ggstatsplot")` |
| Development | [![Project Status](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/##active) | `pak::pak("IndrajeetPatil/ggstatsplot")` |
| Type | Source | Command |
|----|----|----|
| Release | [![CRAN Status](https://www.r-pkg.org/badges/version/ggstatsplot)](https://cran.r-project.org/package=ggstatsplot) | `install.packages("ggstatsplot")` |
| Development | [![Project Status](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/##active) | `pak::pak("IndrajeetPatil/ggstatsplot")` |

## Citation

Expand Down Expand Up @@ -95,17 +95,17 @@ To see the detailed documentation for each function in the stable

## Summary of available plots

| Function | Plot | Description |
|:-------------------|:--------------------------|:------------------------------------------------|
| `ggbetweenstats()` | **violin plots** | for comparisons *between* groups/conditions |
| `ggwithinstats()` | **violin plots** | for comparisons *within* groups/conditions |
| `gghistostats()` | **histograms** | for distribution about numeric variable |
| `ggdotplotstats()` | **dot plots/charts** | for distribution about labeled numeric variable |
| `ggscatterstats()` | **scatterplots** | for correlation between two variables |
| `ggcorrmat()` | **correlation matrices** | for correlations between multiple variables |
| `ggpiestats()` | **pie charts** | for categorical data |
| `ggbarstats()` | **bar charts** | for categorical data |
| `ggcoefstats()` | **dot-and-whisker plots** | for regression models and meta-analysis |
| Function | Plot | Description |
|:---|:---|:---|
| `ggbetweenstats()` | **violin plots** | for comparisons *between* groups/conditions |
| `ggwithinstats()` | **violin plots** | for comparisons *within* groups/conditions |
| `gghistostats()` | **histograms** | for distribution about numeric variable |
| `ggdotplotstats()` | **dot plots/charts** | for distribution about labeled numeric variable |
| `ggscatterstats()` | **scatterplots** | for correlation between two variables |
| `ggcorrmat()` | **correlation matrices** | for correlations between multiple variables |
| `ggpiestats()` | **pie charts** | for categorical data |
| `ggbarstats()` | **bar charts** | for categorical data |
| `ggcoefstats()` | **dot-and-whisker plots** | for regression models and meta-analysis |

In addition to these basic plots, `{ggstatsplot}` also provides
**`grouped_`** versions (see below) that makes it easy to repeat the
Expand All @@ -116,17 +116,17 @@ same analysis for any grouping variable.
The table below summarizes all the different types of analyses currently
supported in this package-

| Functions | Description | Parametric | Non-parametric | Robust | Bayesian |
|:-------------------------------------|:--------------------------------------------------|:-----------|:---------------|:-------|:---------|
| `ggbetweenstats()` | Between group/condition comparisons | | | | |
| `ggwithinstats()` | Within group/condition comparisons | | | | |
| `gghistostats()`, `ggdotplotstats()` | Distribution of a numeric variable | | | | |
| `ggcorrmat` | Correlation matrix | | | | |
| `ggscatterstats()` | Correlation between two variables | | | | |
| `ggpiestats()`, `ggbarstats()` | Association between categorical variables | | | | |
| `ggpiestats()`, `ggbarstats()` | Equal proportions for categorical variable levels | | | | |
| `ggcoefstats()` | Regression model coefficients | | | | |
| `ggcoefstats()` | Random-effects meta-analysis | | | | |
| Functions | Description | Parametric | Non-parametric | Robust | Bayesian |
|:---|:---|:---|:---|:---|:---|
| `ggbetweenstats()` | Between group/condition comparisons |||||
| `ggwithinstats()` | Within group/condition comparisons |||||
| `gghistostats()`, `ggdotplotstats()` | Distribution of a numeric variable |||||
| `ggcorrmat` | Correlation matrix |||||
| `ggscatterstats()` | Correlation between two variables |||||
| `ggpiestats()`, `ggbarstats()` | Association between categorical variables |||||
| `ggpiestats()`, `ggbarstats()` | Equal proportions for categorical variable levels |||||
| `ggcoefstats()` | Regression model coefficients |||||
| `ggcoefstats()` | Random-effects meta-analysis |||||

Summary of Bayesian analysis

Expand Down Expand Up @@ -315,8 +315,6 @@ grouped_gghistostats(
type = "nonparametric",
xlab = "Movies budget (in million US$)",
grouping.var = genre,
normal.curve = TRUE,
normal.curve.args = list(color = "red", size = 1),
ggtheme = ggthemes::theme_tufte(),
## modify the defaults from `{ggstatsplot}` for each plot
plotgrid.args = list(nrow = 1),
Expand Down Expand Up @@ -699,12 +697,18 @@ extract_subtitle(p)
#> list(italic("F")["Welch"](2, 18.03) == "31.62", italic(p) ==
#> "1.27e-06", widehat(omega["p"]^2) == "0.74", CI["95%"] ~
#> "[" * "0.53", "1.00" * "]", italic("n")["obs"] == "32")
```

``` r

# extracting expression present in the caption
extract_caption(p)
#> list(log[e] * (BF["01"]) == "-14.92", widehat(italic(R^"2"))["Bayesian"]^"posterior" ==
#> "0.71", CI["95%"]^HDI ~ "[" * "0.57", "0.79" * "]", italic("r")["Cauchy"]^"JZS" ==
#> "0.71")
```

``` r

# a list of tibbles containing statistical analysis summaries
extract_stats(p)
Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://github.com/tidyverse/ggplot2"
"sameAs": "https://CRAN.R-project.org/package=ggplot2"
},
"7": {
"@type": "SoftwareApplication",
Expand Down Expand Up @@ -532,7 +532,7 @@
},
"SystemRequirements": null
},
"fileSize": "9347.226KB",
"fileSize": "9327.22KB",
"citation": [
{
"@type": "ScholarlyArticle",
Expand Down
Binary file modified man/figures/README-gghistostats2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions man/ggdotplotstats.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5886278

Please sign in to comment.