Skip to content

Commit

Permalink
More linking in docs (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil authored Jul 30, 2024
1 parent 68d299f commit c39cc99
Show file tree
Hide file tree
Showing 38 changed files with 311 additions and 321 deletions.
8 changes: 4 additions & 4 deletions R/combine-plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#'
#' @description
#'
#' Wrapper around `patchwork::wrap_plots()` that will return a combined grid of
#' plots with annotations. In case you want to create a grid of plots, it is
#' Wrapper around [`patchwork::wrap_plots()`] that will return a combined grid
#' of plots with annotations. In case you want to create a grid of plots, it is
#' **highly recommended** that you use `{patchwork}` package directly and not
#' this wrapper around it which is mostly useful with `{ggstatsplot}` plots. It
#' is exported only for backward compatibility.
Expand All @@ -13,10 +13,10 @@
#'
#' @param plotlist A list containing `ggplot` objects.
#' @param plotgrid.args A `list` of additional arguments passed to
#' `patchwork::wrap_plots()`, except for `guides` argument which is already
#' [`patchwork::wrap_plots()`], except for `guides` argument which is already
#' separately specified here.
#' @param annotation.args A `list` of additional arguments passed to
#' `patchwork::plot_annotation()`.
#' [`patchwork::plot_annotation()`].
#' @param ... Currently ignored.
#' @inheritParams patchwork::wrap_plots
#'
Expand Down
3 changes: 2 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
#' - id. Dummy identity number for each flower (150 flowers in total).
#' - Species. The species are *Iris setosa*, *versicolor*, and *virginica*.
#' - condition. Factor giving a detailed description of the attribute
#' (Four levels: `"Petal.Length"`, `"Petal.Width"`, `"Sepal.Length"`, `"Sepal.Width"`).
#' (Four levels: `"Petal.Length"`, `"Petal.Width"`, `"Sepal.Length"`,
#' `"Sepal.Width"`).
#' - attribute. What attribute is being measured (`"Sepal"` or `"Pepal"`).
#' - measure. What aspect of the attribute is being measured (`"Length"` or `"Width"`).
#' - value. Value of the measurement.
Expand Down
2 changes: 1 addition & 1 deletion R/extract-stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'
#' The only exception is the `ggcorrmat()` function. But, if a data frame is
#' what you want, you shouldn't be using `ggcorrmat()` anyway. You can use
#' `correlation::correlation()` function which provides tidy data frames by
#' [`correlation::correlation()`] function which provides tidy data frames by
#' default.
#'
#' @returns
Expand Down
4 changes: 2 additions & 2 deletions R/ggbarstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#'
#' @inheritParams ggpiestats
#' @inheritParams ggbetweenstats
#' @param sample.size.label.args Additional aesthetic arguments that will be passed to
#' `ggplot2::geom_text()`.
#' @param sample.size.label.args Additional aesthetic arguments that will be
#' passed to [`ggplot2::geom_text()`].
#'
#' @inheritSection statsExpressions::contingency_table Contingency table analyses
#'
Expand Down
2 changes: 1 addition & 1 deletion R/ggbetweenstats-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#' @param ... Currently ignored.
#' @param plot A `ggplot` object on which `geom_signif` needed to be added.
#' @param mpc_df A data frame containing results from pairwise comparisons
#' (produced by `pairwise_comparisons()` function).
#' (produced by [`pairwise_comparisons()`] function).
#' @inheritParams ggbetweenstats
#'
#' @autoglobal
Expand Down
26 changes: 13 additions & 13 deletions R/ggbetweenstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
#'
#' Just as `type` argument, abbreviations are also accepted.
#' @param point.args A list of additional aesthetic arguments to be passed to
#' the `ggplot2::geom_point()` displaying the raw data.
#' the [`ggplot2::geom_point()`].
#' @param boxplot.args A list of additional aesthetic arguments passed on to
#' `ggplot2::geom_boxplot()`.
#' [`ggplot2::geom_boxplot()`].
#' @param violin.args A list of additional aesthetic arguments to be passed to
#' the `ggplot2::geom_violin()`.
#' the [`ggplot2::geom_violin()`].
#' @param ggplot.component A `ggplot` component to be added to the plot prepared
#' by `{ggstatsplot}`. This argument is primarily helpful for `grouped_`
#' variants of all primary functions. Default is `NULL`. The argument should
Expand All @@ -76,18 +76,18 @@
#' @param ... Currently ignored.
#' @inheritParams theme_ggstatsplot
#' @param centrality.point.args,centrality.label.args A list of additional aesthetic
#' arguments to be passed to `ggplot2::geom_point()` and
#' `ggrepel::geom_label_repel` geoms, which are involved in mean plotting.
#' arguments to be passed to [`ggplot2::geom_point()`] and
#' [`ggrepel::geom_label_repel()`] geoms, which are involved in mean plotting.
#' @param ggsignif.args A list of additional aesthetic
#' arguments to be passed to `ggsignif::geom_signif`.
#' arguments to be passed to [`ggsignif::geom_signif()`].
#' @param ggtheme A `{ggplot2}` theme. Default value is
#' `ggstatsplot::theme_ggstatsplot()`. Any of the `{ggplot2}` themes (e.g.,
#' `theme_bw()`), or themes from extension packages are allowed (e.g.,
#' `ggthemes::theme_fivethirtyeight()`, `hrbrthemes::theme_ipsum_ps()`, etc.).
#' But note that sometimes these themes will remove some of the details that
#' `{ggstatsplot}` plots typically contains. For example, if relevant,
#' `ggbetweenstats()` shows details about multiple comparison test as a label
#' on the secondary Y-axis. Some themes (e.g.
#' [`ggstatsplot::theme_ggstatsplot()`]. Any of the `{ggplot2}` themes (e.g.,
#' [`ggplot2::theme_bw()`]), or themes from extension packages are allowed
#' (e.g., `ggthemes::theme_fivethirtyeight()`, `hrbrthemes::theme_ipsum_ps()`,
#' etc.). But note that sometimes these themes will remove some of the details
#' that `{ggstatsplot}` plots typically contains. For example, if relevant,
#' [`ggbetweenstats()`] shows details about multiple comparison test as a
#' label on the secondary Y-axis. Some themes (e.g.
#' `ggthemes::theme_fivethirtyeight()`) will remove the secondary Y-axis and
#' thus the details as well.
#' @inheritParams statsExpressions::oneway_anova
Expand Down
22 changes: 9 additions & 13 deletions R/ggcoefstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,21 @@
#' ```
#'
#' @param x A model object to be tidied, or a tidy data frame from a regression
#' model. Function internally uses `parameters::model_parameters()` to get a
#' model. Function internally uses [`parameters::model_parameters()`] to get a
#' tidy data frame. If a data frame, it *must* contain at the minimum two
#' columns named `term` (names of predictors) and `estimate` (corresponding
#' estimates of coefficients or other quantities of interest).
#' @param statistic Relevant statistic for the model (`"t"`, `"f"`, `"z"`, or
#' `"chi"`) in the label. Relevant only if `x` is a *data frame*.
#' @param effectsize.type This is the same as `es_type` argument of
#' `parameters::model_parameters()`. Defaults to `"eta"`, and relevant for
#' [`parameters::model_parameters()`]. Defaults to `"eta"`, and relevant for
#' ANOVA-like objects.
#' @param bf.message Logical that decides whether results from running a
#' Bayesian meta-analysis assuming that the effect size *d* varies across
#' studies with standard deviation *t* (i.e., a random-effects analysis)
#' should be displayed in caption. Defaults to `TRUE`.
#' @param subtitle The text for the plot subtitle. The input to this argument
#' will be ignored if `meta.analytic.effect` is set to `TRUE`.
#' @param point.args Additional arguments that will be passed to
#' `geom_point` geom. Please see documentation for that function to
#' know more about these arguments.
#' @param conf.int Logical. Decides whether to display confidence intervals as
#' error bars (Default: `TRUE`).
#' @param conf.level Numeric deciding level of confidence or credible intervals
Expand All @@ -41,13 +38,13 @@
#' relevant if a data frame with estimates and their standard errors is
#' entered.
#' @param meta.type Type of statistics used to carry out random-effects
#' meta-analysis. If `"parametric"` (default), `metafor::rma` function will be
#' used. If `"robust"`, `metaplus::metaplus` function will be used. If
#' `"bayes"`, `metaBMA::meta_random` function will be used.
#' meta-analysis. If `"parametric"` (default), [`metafor::rma()`] will be
#' used. If `"robust"`, [`metaplus::metaplus()`] will be used. If `"bayes"`,
#' [`metaBMA::meta_random()`] will be used.
#' @param exclude.intercept Logical that decides whether the intercept should be
#' excluded from the plot (Default: `FALSE`).
#' @param errorbar.args Additional arguments that will be passed to
#' `geom_errorbarh` geom. Please see documentation for that function
#' `geom_errorbarh()` geom. Please see documentation for that function
#' to know more about these arguments.
#' @param vline Decides whether to display a vertical line (Default: `"TRUE"`).
#' @param vline.args Additional arguments that will be passed to
Expand All @@ -58,18 +55,17 @@
#' coefficient value.
#' @param stats.labels Logical. Decides whether the statistic and *p*-values for
#' each coefficient are to be attached to each dot as a text label using
#' `ggrepel` (Default: `TRUE`).
#' `{ggrepel}` (Default: `TRUE`).
#' @param stats.label.color Color for the labels. If set to `NULL`, colors will
#' be chosen from the specified `package` (Default: `"RColorBrewer"`) and
#' `palette` (Default: `"Dark2"`).
#' @param stats.label.args Additional arguments that will be passed to
#' `ggrepel::geom_label_repel()`. Please see documentation for that
#' function to know more about these arguments.
#' [`ggrepel::geom_label_repel()`].
#' @param only.significant If `TRUE`, only stats labels for significant effects
#' is shown (Default: `FALSE`). This can be helpful when a large number of
#' regression coefficients are to be displayed in a single plot.
#' @param ... Additional arguments to tidying method. For more, see
#' `parameters::model_parameters`.
#' [`parameters::model_parameters()`].
#' @inheritParams parameters::model_parameters
#' @inheritParams theme_ggstatsplot
#' @inheritParams statsExpressions::meta_analysis
Expand Down
12 changes: 6 additions & 6 deletions R/ggcorrmat.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#' @description
#' Correlation matrix containing results from pairwise correlation tests.
#' If you want a data frame of (grouped) correlation matrix, use
#' `correlation::correlation()` instead. It can also do grouped analysis when
#' used with output from `dplyr::group_by()`.
#' [`correlation::correlation()`] instead. It can also do grouped analysis when
#' used with output from [`dplyr::group_by()`].
#'
#' @section Summary of graphics:
#'
Expand Down Expand Up @@ -34,10 +34,10 @@
#' @param pch Decides the point shape to be used for insignificant correlation
#' coefficients (only valid when `insig = "pch"`). Default: `pch = "cross"`.
#' @param ggcorrplot.args A list of additional (mostly aesthetic) arguments that
#' will be passed to `ggcorrplot::ggcorrplot()` function. The list should avoid
#' any of the following arguments since they are already internally being
#' used: `corr`, `method`, `p.mat`, `sig.level`, `ggtheme`, `colors`, `lab`,
#' `pch`, `legend.title`, `digits`.
#' will be passed to [`ggcorrplot::ggcorrplot()`] function. The list should
#' avoid any of the following arguments since they are already internally
#' being used: `corr`, `method`, `p.mat`, `sig.level`, `ggtheme`, `colors`,
#' `lab`, `pch`, `legend.title`, `digits`.
#' @inheritParams statsExpressions::corr_test
#' @inheritParams ggbetweenstats
#' @inheritParams theme_ggstatsplot
Expand Down
3 changes: 1 addition & 2 deletions R/ggdotplotstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
#'
#' @param ... Currently ignored.
#' @param y Label or grouping variable.
#' @param point.args A list of additional aesthetic arguments passed to
#' `geom_point`.
#' @inheritParams gghistostats
#' @inheritParams ggcoefstats
#' @inheritParams ggbetweenstats
#'
#' @inheritSection statsExpressions::one_sample_test One-sample tests
#'
Expand Down
4 changes: 2 additions & 2 deletions R/gghistostats.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#' `stat_bin` used to display the bins. Do not specify `binwidth` argument in
#' this list since it has already been specified using the dedicated argument.
#' @param centrality.line.args A list of additional aesthetic arguments to be
#' passed to the `geom_line` used to display the lines corresponding to the
#' centrality parameter.
#' passed to the [`ggplot2::geom_line()`] used to display the lines
#' corresponding to the centrality parameter.
#' @inheritParams statsExpressions::one_sample_test
#' @inheritParams ggbetweenstats
#'
Expand Down
2 changes: 1 addition & 1 deletion R/ggpiestats-ggbarstats-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ onesample_data <- function(data, x, y, digits = 2L, ratio = NULL, ...) {


#' Safer version of chi-squared test that returns `NA`s
#' Needed to work with `group_modify()` since it will not work when `NULL` is returned
#' Needed to work with `dplyr::group_modify()` since it will not work when `NULL` is returned.
#' @autoglobal
#' @noRd
.chisq_test_safe <- function(data, x, ratio) {
Expand Down
14 changes: 7 additions & 7 deletions R/ggpiestats.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
#' will be dropped. Default is `NULL`. If `NULL`, one-sample proportion test
#' (a goodness of fit test) will be run for the `x` variable. Otherwise an
#' appropriate association test will be run. This argument can not be `NULL`
#' for `ggbarstats` function.
#' for [`ggbarstats()`].
#' @param proportion.test Decides whether proportion test for `x` variable is to
#' be carried out for each level of `y`. Defaults to `results.subtitle`. In
#' `ggbarstats`, only *p*-values from this test will be displayed.
#' @param digits.perc Numeric that decides number of decimal places for percentage
#' labels (Default: `0L`).
#' [`ggbarstats()`], only *p*-values from this test will be displayed.
#' @param digits.perc Numeric that decides number of decimal places for
#' percentage labels (Default: `0L`).
#' @param label Character decides what information needs to be displayed
#' on the label in each pie slice. Possible options are `"percentage"`
#' (default), `"counts"`, `"both"`.
#' @param label.args Additional aesthetic arguments that will be passed to
#' `ggplot2::geom_label()`.
#' @param label.repel Whether labels should be repelled using `{ggrepel}` package.
#' This can be helpful in case the labels are overlapping.
#' [`ggplot2::geom_label()`].
#' @param label.repel Whether labels should be repelled using `{ggrepel}`
#' package. This can be helpful in case of overlapping labels.
#' @param legend.title Title text for the legend.
#' @inheritParams ggbetweenstats
#' @inheritParams statsExpressions::contingency_table
Expand Down
17 changes: 6 additions & 11 deletions R/ggscatterstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
#' `var1`).
#' @param label.expression An expression evaluating to a logical vector that
#' determines the subset of data points to label (e.g. `y < 4 & z < 20`).
#' While using this argument with `purrr::pmap()`, you will have to provide a
#' quoted expression (e.g. `quote(y < 4 & z < 20)`).
#' While using this argument with [`purrr::pmap()`], you will have to provide
#' a quoted expression (e.g. `quote(y < 4 & z < 20)`).
#' @param point.label.args A list of additional aesthetic arguments to be passed
#' to `ggrepel::geom_label_repel` geom used to display the labels.
#' to [`ggrepel::geom_label_repel()`]geom used to display the labels.
#' @param smooth.line.args A list of additional aesthetic arguments to be passed
#' to `geom_smooth` geom used to display the regression line.
#' @param point.args A list of additional aesthetic arguments to be passed
#' to `geom_point` geom used to display the raw data points.
#' @param marginal Decides whether marginal distributions will be plotted on
#' axes using `ggside` functions. The default is `TRUE`. The package
#' `ggside` must already be installed by the user.
#' axes using `{ggside}` functions. The default is `TRUE`. The package
#' `{ggside}` must already be installed by the user.
#' @param point.width.jitter,point.height.jitter Degree of jitter in `x` and `y`
#' direction, respectively. Defaults to `0` (0%) of the resolution of the
#' data. Note that the jitter should not be specified in the `point.args`
Expand All @@ -52,7 +50,7 @@
#' <https://indrajeetpatil.github.io/ggstatsplot/articles/web_only/ggscatterstats.html>
#'
#' @note
#' The plot uses `ggrepel::geom_label_repel()` to attempt to keep labels
#' The plot uses [`ggrepel::geom_label_repel()`] to attempt to keep labels
#' from over-lapping to the largest degree possible. As a consequence plot
#' times will slow down massively (and the plot file will grow in size) if you
#' have a lot of labels that overlap.
Expand Down Expand Up @@ -130,7 +128,6 @@ ggscatterstats <- function(
subtitle_df <- .eval_f(corr_test, !!!.f.args, type = type)
subtitle <- .extract_expression(subtitle_df)

# BF message for null hypothesis support
if (type == "parametric" && bf.message) {
caption_df <- .eval_f(corr_test, !!!.f.args, type = "bayes")
caption <- .extract_expression(caption_df)
Expand All @@ -139,10 +136,8 @@ ggscatterstats <- function(

# basic plot ------------------------------------------

# creating jittered positions
pos <- position_jitter(width = point.width.jitter, height = point.height.jitter)

# scatterplot
plot_scatter <- ggplot(data, mapping = aes({{ x }}, {{ y }})) +
exec(geom_point, position = pos, !!!point.args) +
exec(geom_smooth, level = conf.level, !!!smooth.line.args, na.rm = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion R/ggstatsplot-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#' - `ggcoefstats()` function to visualize results from regression analyses.
#'
#' - `combine_plots()` helper function to combine multiple `{ggstatsplot}`
#' plots using `patchwork::wrap_plots()`.
#' plots using [`patchwork::wrap_plots()`].
#'
#' References: Patil (2021) \doi{10.21105/joss.03236}.
#'
Expand Down
4 changes: 2 additions & 2 deletions R/ggwithinstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#' @inheritParams ggbetweenstats
#' @param point.path,centrality.path Logical that decides whether individual
#' data points and means, respectively, should be connected using
#' `ggplot2::geom_path()`. Both default to `TRUE`. Note that `point.path`
#' [`ggplot2::geom_path()`]. Both default to `TRUE`. Note that `point.path`
#' argument is relevant only when there are two groups (i.e., in case of a
#' *t*-test). In case of large number of data points, it is advisable to set
#' `point.path = FALSE` as these lines can overwhelm the plot.
#' @param centrality.path.args,point.path.args A list of additional aesthetic
#' arguments passed on to `ggplot2::geom_path()` connecting raw data points
#' arguments passed on to [`ggplot2::geom_path()`] connecting raw data points
#' and mean points.
#' @inheritParams statsExpressions::oneway_anova
#'
Expand Down
6 changes: 3 additions & 3 deletions R/theme-ggstatsplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#' @description
#'
#' Common theme used across all plots generated in `{ggstatsplot}` and *assumed*
#' by the author to be aesthetically pleasing to the user/reader. The theme is a
#' wrapper around `theme_bw()`.
#' by the author to be aesthetically pleasing to the user. The theme is a
#' wrapper around [`ggplot2::theme_bw()`].
#'
#' All `{ggstatsplot}` functions have a `ggtheme` parameter that let you choose
#' a different theme.
#'
#' @returns A `ggplot` object with the `theme_ggstatsplot` theme overlaid.
#' @returns A `ggplot` object.
#'
#' @examples
#' library(ggplot2)
Expand Down
8 changes: 4 additions & 4 deletions man/combine_plots.Rd

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

Loading

0 comments on commit c39cc99

Please sign in to comment.