Wrapper Function for ggstatsplot::ggscatterstats and ggstatsplot::grouped_ggscatterstats to generate scatter plots with correlation analysis and optional marginal distributions.
Usage
jjscatterstats(
data,
dep,
group,
grvar,
typestatistics = "parametric",
mytitle = "",
xtitle = "",
ytitle = "",
originaltheme = FALSE,
resultssubtitle = TRUE,
conflevel = 0.95,
bfmessage = TRUE,
k = 2,
marginal = TRUE,
xsidefill = "#009E73",
ysidefill = "#D55E00",
pointsize = 3,
pointalpha = 0.4,
smoothlinesize = 1.5,
smoothlinecolor = "blue"
)
Arguments
- data
The data as a data frame.
- dep
.
- group
.
- grvar
.
- typestatistics
.
- mytitle
.
- xtitle
.
- ytitle
.
- originaltheme
.
- resultssubtitle
.
- conflevel
Confidence level for confidence intervals (between 0 and 1).
- bfmessage
Whether to display Bayes Factor in the subtitle when using Bayesian analysis.
- k
Number of decimal places for displaying statistics in the subtitle.
- marginal
Whether to display marginal histogram plots on the axes using ggside.
- xsidefill
Fill color for x-axis marginal histogram.
- ysidefill
Fill color for y-axis marginal histogram.
- pointsize
Size of the scatter plot points.
- pointalpha
Transparency level for scatter plot points.
- smoothlinesize
Width of the regression/smooth line.
- smoothlinecolor
Color of the regression/smooth line.
Examples
# \donttest{
# Load test data
data("mtcars")
# Basic scatter plot with correlation
jjscatterstats(
data = mtcars,
dep = "mpg", # x-axis
group = "hp", # y-axis
typestatistics = "parametric",
conflevel = 0.95,
k = 2
)
#> Error in jjscatterstats(data = mtcars, dep = "mpg", group = "hp", typestatistics = "parametric", conflevel = 0.95, k = 2): argument "grvar" is missing, with no default
# Scatter plot with marginal histograms
jjscatterstats(
data = mtcars,
dep = "mpg",
group = "hp",
marginal = TRUE,
xsidefill = "#009E73",
ysidefill = "#D55E00",
pointsize = 4,
pointalpha = 0.6,
smoothlinesize = 2,
smoothlinecolor = "red"
)
#> Error in jjscatterstats(data = mtcars, dep = "mpg", group = "hp", marginal = TRUE, xsidefill = "#009E73", ysidefill = "#D55E00", pointsize = 4, pointalpha = 0.6, smoothlinesize = 2, smoothlinecolor = "red"): argument "grvar" is missing, with no default
# Grouped scatter plot by number of cylinders
jjscatterstats(
data = mtcars,
dep = "mpg",
group = "hp",
grvar = "cyl",
typestatistics = "nonparametric",
bfmessage = FALSE,
resultssubtitle = TRUE
)
#>
#> SCATTER PLOT
#>
#> You have selected to use a scatter plot.
# }