Scatterplots from ggplot2
combined with marginal
histograms/boxplots/density plots with statistical details added as a
subtitle.
ggscatterstats(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", xalpha = 1, yalpha = 1, xsize = 0.7,
ysize = 0.7, centrality.para = NULL, type = "pearson",
results.subtitle = NULL, title = NULL, caption = NULL,
nboot = 100, beta = 0.1, k = 3, axes.range.restrict = FALSE,
ggtheme = ggplot2::theme_bw(), messages = TRUE)
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"
, "densigram"
).
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.
Character describing color fill for x
and y
axes
marginal distributions (default: "#009E73"
(for x
) and "#D55E00"
(for
y
)).
Numeric deciding transparency levels for the marginal
distributions. Any numbers from 0
(transparent) to 1
(opaque). The
default is 1
for both axes.
Size for the marginal distribution boundaries (Default: 0.7
).
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 title.
The text for the plot caption.
Number of bootstrap samples for computing effect size (Default:
100
).
bending constant (Default: 0.1
). For more, see ?WRS2::pbcor
.
Number of decimal places expected for results.
Logical decides whether to restrict the axes values
ranges to min and max values of the x
and y
variables (Default: FALSE
).
A function, ggplot2
theme name. Default value is
ggplot2::theme_bw()
. Allowed values are the official ggplot2
themes,
including theme_grey()
, theme_minimal()
, theme_classic()
,
theme_void()
, etc.
Decides whether messages references, notes, and warnings are
to be displayed (Default: TRUE
).
https://indrajeetpatil.github.io/ggstatsplot/articles/ggscatterstats.html
# NOT RUN {
# to get reproducible results from bootstrapping
set.seed(123)
# simple function call with the defaults
ggstatsplot::ggscatterstats(
data = datasets::mtcars,
x = wt,
y = mpg,
type = "np"
)
# }
Run the code above in your browser using DataLab