ggstatsplot (version 0.0.3)

grouped_ggscatterstats: Scatterplot with marginal distributions for all levels of a grouping variable

Description

Grouped scatterplots from ggplot2 combined with marginal histograms/boxplots/density plots with statistical details added as a subtitle.

Usage

grouped_ggscatterstats(grouping.var, title.prefix = "Group", data, x, y,
  xlab = NULL, ylab = NULL, line.size = 1.5, line.color = "blue",
  marginal = TRUE, marginal.type = "histogram", marginal.size = 5,
  margins = c("both", "x", "y"), width.jitter = NULL,
  height.jitter = NULL, xfill = "#009E73", yfill = "#D55E00",
  centrality.para = NULL, type = "pearson", results.subtitle = NULL,
  caption = NULL, maxit = 500, k = 3, axes.range.restrict = FALSE,
  messages = TRUE, ...)

Arguments

grouping.var

Grouping variable.

title.prefix

Character specifying the prefix text for the fixed plot title (name of each factor level) (Default: "Group").

data

Dataframe from which variables specified are preferentially to be taken.

x

A vector containing the explanatory variable.

y

The response - a vector of length the number of rows of x.

xlab

Label for x axis variable.

ylab

Label for y axis variable.

line.size

Size for the regression line.

line.color

color for the regression line.

marginal

Decides whether ggExtra::ggMarginal() plots will be displayed; the default is TRUE.

marginal.type

Type of marginal distribution to be plotted on the axes ("histogram", "boxplot", "density", "violin").

marginal.size

Integer describing the relative size of the marginal plots compared to the main plot. A size of 5 means that the main plot is 5x wider and 5x taller than the marginal plots.

margins

Character describing along which margins to show the plots. Any of the following arguments are accepted: "both", "x", "y".

width.jitter

Degree of jitter in x direction. Defaults to 40% of the resolution of the data.

height.jitter

Degree of jitter in y direction. Defaults to 40% of the resolution of the data.

xfill

color fill for x axis distibution (default: "#009E73").

yfill

color fill for y axis distribution (default: "#D55E00").

centrality.para

Decides which measure of central tendency ("mean" or "median") is to be displayed as vertical (for x) and horizontal (for y) lines.

type

Type of association between paired samples required (""parametric": Pearson's product moment correlation coefficient" or ""nonparametric": Spearman's rho" or ""robust": Robust regression using an M estimator"). Corresponding abbreviations are also accepted: "p" (for parametric/pearson's), "np" (nonparametric/spearman), "r" (robust), resp.

results.subtitle

Decides whether the results of statistical tests are to be displayed as subtitle.

caption

The text for the plot caption.

maxit

Maximum number of iterations for robust linear regression or bootstrap samples to compute Spearman's rho confidence intervals (Default: 500).

k

Number of decimal places expected for results.

axes.range.restrict

Logical decides whther to restrict the axes values ranges to min and max values of the x and y variables (Default: FALSE).

messages

Decides whether messages references, notes, and warnings are to be displayed (Default: TRUE).

...

Arguments passed on to combine_plots

title.text

String or plotmath expression to be drawn as title for the combined plot.

title.color

Text color for title.

title.size

Point size of title text.

title.vjust

Vertical justification for title. Default = 0.5 (centered on y). 0 = baseline at y, 1 = ascender at y.

title.hjust

Horizontal justification for title. Default = 0.5 (centered on x). 0 = flush-left at x, 1 = flush-right.

title.fontface

The font face ("plain", "bold", etc.) for title.

caption.text

String or plotmath expression to be drawn as the caption for the combined plot.

caption.color

Text color for caption.

caption.size

Point size of title text.

caption.vjust

Vertical justification for caption. Default = 0.5 (centered on y). 0 = baseline at y, 1 = ascender at y.

caption.hjust

Horizontal justification for caption. Default = 0.5 (centered on x). 0 = flush-left at x, 1 = flush-right.

caption.fontface

The font face ("plain", "bold", "italic", "bold.italic") for caption.

sub.text

The label with which the combined plot should be annotated. Can be a plotmath expression.

sub.color

Text color for annotation label.

sub.size

Point size of annotation text.

sub.x

The x position of annotation label.

sub.y

The y position of annotation label.

sub.hjust

Horizontal justification for annotation label.

sub.vjust

Vertical justification for annotation label.

sub.vpadding

Vertical padding. The total vertical space added to the label, given in grid units. By default, this is added equally above and below the label. However, by changing the y and vjust parameters, this can be changed.

sub.fontface

The font face ("plain", "bold", "italic", "bold.italic") for the annotation label.

sub.angle

Angle at which annotation label is to be drawn.

sub.lineheight

Line height of annotation label.

title.caption.rel.heights

Numerical vector of relative columns heights while combining (title, plot, caption).

title.rel.heights

Numerical vector of relative columns heights while combining (title, plot).

caption.rel.heights

Numerical vector of relative columns heights while combining (plot, caption).

See Also

ggscatterstats ggcorrmat grouped_ggcorrmat

Examples

Run this code
# NOT RUN {
# to ensure reproducibility
set.seed(123)

# basic functio call
ggstatsplot::grouped_ggscatterstats(
 data = datasets::iris,
 x = Sepal.Length,
 y = Sepal.Width,
 grouping.var = Species,
 messages = FALSE
)

# }

Run the code above in your browser using DataCamp Workspace