R/ggscatterstats.R
ggscatterstats.Rd
Scatterplots from ggplot2
combined with marginal
histograms/boxplots/density plots with statistical details added as a
subtitle.
ggscatterstats( data, x, y, type = "pearson", conf.level = 0.95, bf.prior = 0.707, bf.message = TRUE, label.var = NULL, label.expression = NULL, xlab = NULL, ylab = NULL, method = "lm", method.args = list(), formula = y ~ x, point.color = "black", point.size = 3, point.alpha = 0.4, point.width.jitter = 0, point.height.jitter = 0, line.size = 1.5, line.color = "blue", marginal = TRUE, marginal.type = "histogram", marginal.size = 5, margins = c("both", "x", "y"), package = "wesanderson", palette = "Royal1", direction = 1, xfill = "#009E73", yfill = "#D55E00", xalpha = 1, yalpha = 1, xsize = 0.7, ysize = 0.7, centrality.para = NULL, results.subtitle = TRUE, stat.title = NULL, title = NULL, subtitle = NULL, caption = NULL, nboot = 100, beta = 0.1, k = 2, axes.range.restrict = FALSE, ggtheme = ggplot2::theme_bw(), ggstatsplot.layer = TRUE, ggplot.component = NULL, return = "plot", messages = TRUE )
data  A dataframe (or a tibble) from which variables specified are to be taken. A matrix or tables will not be accepted. 

x  The column in 
y  The column in 
type  Type of association between paired samples required
(" 
conf.level  Scalar between 0 and 1. If unspecified, the defaults return

bf.prior  A numeric value between 
bf.message  Logical that decides whether to display Bayes Factor in
favor of the null hypothesis. This argument is relevant only for
parametric test (Default: 
label.var  Variable to use for points labels. Can be entered either as
a character string (e.g., 
label.expression  An expression evaluating to a logical vector that
determines the subset of data points to label. This argument can be entered
either as a character string (e.g., 
xlab  Labels for 
ylab  Labels for 
method  Smoothing method (function) to use, accepts either a character vector,
e.g. For If you have fewer than 1,000 observations but want to use the same 
method.args  List of additional arguments passed on to the modelling
function defined by 
formula  Formula to use in smoothing function, eg. 
point.color, point.size, point.alpha  Aesthetics specifying geom point
(defaults: 
point.width.jitter, point.height.jitter  Degree of jitter in 
line.size  Size for the regression line. 
line.color  color for the regression line. 
marginal  Decides whether 
marginal.type  Type of marginal distribution to be plotted on the axes
( 
marginal.size  Integer describing the relative size of the marginal
plots compared to the main plot. A size of 
margins  Character describing along which margins to show the plots.
Any of the following arguments are accepted: 
package  Name of package from which the palette is desired as string or symbol. 
palette  Name of palette as string or symbol. 
direction  Either 
xfill, yfill  Character describing color fill for 
xalpha, yalpha  Numeric deciding transparency levels for the marginal
distributions. Any numbers from 
xsize, ysize  Size for the marginal distribution boundaries (Default:

centrality.para  Decides which measure of central tendency ( 
results.subtitle  Decides whether the results of statistical tests are
to be displayed as a subtitle (Default: 
stat.title  A character describing the test being run, which will be
added as a prefix in the subtitle. The default is 
title  The text for the plot title. 
subtitle  The text for the plot subtitle. Will work only if

caption  The text for the plot caption. 
nboot  Number of bootstrap samples for computing confidence interval
for the effect size (Default: 
beta  bending constant (Default: 
k  Number of digits after decimal point (should be an integer)
(Default: 
axes.range.restrict  Logical that decides whether to restrict the axes
values ranges to 
ggtheme  A function, 
ggstatsplot.layer  Logical that decides whether 
ggplot.component  A 
return  Character that describes what is to be returned: can be

messages  Decides whether messages references, notes, and warnings are
to be displayed (Default: 
The plot uses ggrepel::geom_label_repel
to attempt to keep labels
from overlapping 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.
https://indrajeetpatil.github.io/ggstatsplot/articles/web_only/ggscatterstats.html
# \donttest{ # to get reproducible results from bootstrapping set.seed(123) # creating dataframe with rownames converted to a new column mtcars_new < mtcars %>% tibble::rownames_to_column(., var = "car") %>% tibble::as_tibble(x = .) # simple function call with the defaults ggstatsplot::ggscatterstats( data = mtcars_new, x = wt, y = mpg, type = "np", label.var = car, label.expression = wt < 4 & mpg < 20, axes.range.restrict = TRUE, centrality.para = "median", xfill = NULL )#>#> Warning: This plot can't be further modified with `ggplot2` functions. #> In case you want a `ggplot` object, set `marginal = FALSE`.#># }