Grouped scatterplots from ggplot2
combined with marginal
histograms/boxplots/density plots with statistical details added as a
subtitle.
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, ...)
Grouping variable.
Character specifying the prefix text for the fixed plot
title (name of each factor level) (Default: "Group"
).
Dataframe from which variables specified are preferentially to be taken.
A vector containing the explanatory variable.
The response - a vector of length the number of rows of x
.
Label for x
axis variable.
Label for y
axis variable.
Size for the regression line.
color for the regression line.
Decides whether ggExtra::ggMarginal()
plots will be
displayed; the default is TRUE
.
Type of marginal distribution to be plotted on the axes
("histogram"
, "boxplot"
, "density"
, "violin"
).
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.
Character describing along which margins to show the plots.
Any of the following arguments are accepted: "both"
, "x"
, "y"
.
Degree of jitter in x
direction. Defaults to 40% of
the resolution of the data.
Degree of jitter in y
direction. Defaults to 40% of
the resolution of the data.
color fill for x axis distibution (default: "#009E73"
).
color fill for y axis distribution (default: "#D55E00"
).
Decides which measure of central tendency ("mean"
or "median"
) is to be displayed as vertical (for x
) and horizontal (for
y
) lines.
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.
Decides whether the results of statistical tests are to be displayed as subtitle.
The text for the plot caption.
Maximum number of iterations for robust linear regression or
bootstrap samples to compute Spearman's rho confidence intervals (Default:
500
).
Number of decimal places expected for results.
Logical decides whther to restrict the axes values
ranges to min and max values of the x
and y
variables (Default: FALSE
).
Decides whether messages references, notes, and warnings are
to be displayed (Default: TRUE
).
Arguments passed on to combine_plots
String or plotmath expression to be drawn as title for the combined plot.
Text color for title.
Point size of title text.
Vertical justification for title. Default = 0.5 (centered on y). 0 = baseline at y, 1 = ascender at y.
Horizontal justification for title. Default = 0.5 (centered on x). 0 = flush-left at x, 1 = flush-right.
The font face ("plain", "bold", etc.) for title.
String or plotmath expression to be drawn as the caption for the combined plot.
Text color for caption.
Point size of title text.
Vertical justification for caption. Default = 0.5
(centered on y). 0
= baseline at y, 1
= ascender at y.
Horizontal justification for caption. Default = 0.5
(centered on x). 0
= flush-left at x, 1
= flush-right.
The font face ("plain"
, "bold"
, "italic"
,
"bold.italic"
) for caption.
The label with which the combined plot should be annotated. Can be a plotmath expression.
Text color for annotation label.
Point size of annotation text.
The x position of annotation label.
The y position of annotation label.
Horizontal justification for annotation label.
Vertical justification for annotation label.
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.
The font face ("plain"
, "bold"
, "italic"
,
"bold.italic"
) for the annotation label.
Angle at which annotation label is to be drawn.
Line height of annotation label.
Numerical vector of relative columns heights while combining (title, plot, caption).
Numerical vector of relative columns heights while combining (title, plot).
Numerical vector of relative columns heights while combining (plot, caption).
# 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