ggcorr | R Documentation |
Plots a scatterplot with various correlation coefficients and an optional ab-line overlaid.
ggcorr(
data,
corr_method = "spearman",
corr_lab = "auto",
grp,
grp_base = NULL,
grp_x = NULL,
grp_lab = "auto",
y,
id,
est_signif = 3,
ci = TRUE,
pval = TRUE,
ci_signif = 3,
pval_signif = 3,
pval_trunc = 0.001,
label_id = FALSE,
label_id_size = 3,
trans = "identity",
coord = c(0.05, 0.95),
skip = 0.05,
font_size = 4.2,
hjust = 0,
vjust = 0.5,
point_size = 1,
point_alpha = 0.9,
limits_expand = NULL,
limits_equal = FALSE,
legend_title = FALSE,
legend_position = "bottom",
thm = cowplot::theme_cowplot() + theme(plot.background = element_rect(fill = "white")),
grid = cowplot::background_grid(major = "xy"),
grp_to_col = NULL,
abline = FALSE,
smooth = TRUE,
smooth_method = "lm",
smooth_se = FALSE
)
data |
dataframe. Dataframe containing the data to be plotted. |
corr_method |
character vector. Correlation method. One or more of
|
corr_lab |
|
grp |
character. Name of the column in |
grp_base |
character. If not |
grp_x |
character. If |
grp_lab |
|
y |
character. Name of the column in |
id |
character. Name of the column in |
est_signif |
numeric. Significant digits for correlation estimates.
Default is |
ci |
logical. Whether to include confidence intervals for correlation
estimates. Default is |
pval |
logical. Whether to include p-values for correlation estimates.
Default is |
ci_signif |
numeric. Significant digits for confidence intervals.
Default is |
pval_signif |
numeric. Significant digits for p-values. Default is |
pval_trunc |
numeric. P-values smaller than this threshold will be
displayed as "< threshold". Default is |
label_id |
logical. If |
label_id_size |
numeric. Size of labels. Default is |
trans |
character or trans object. Specifies scaling of y- and x-axes.
If class is character, it is converted to a trans object. Adds "root_cube",
"root_fourth", "root_fifth" and "asinh" transformations, as well as "sqrt"
transformation that allows plotting of lines at zero. If class is a trans
object, it is returned as is. Default is |
coord |
numeric vector.
Coordinates for text placement for first (or only) row of results.
Specified in terms of proportion of axis length,
with the first value specifying the x-axis coordinate and the second
value the y-axis coordinate.
Default is |
skip |
numeric.
Proportion of y-axis to move down between lines of text.
Default is |
font_size |
numeric. Font size for text in results table. Default is |
hjust |
numeric. Horizontal justification for text. Default is |
vjust |
numeric. Vertical justification for text. Default is |
point_size |
numeric. Size of points. Default is |
point_alpha |
numeric. Alpha value for points. Default is |
limits_expand |
list. Expand the axis limits. Default is |
limits_equal |
logical. Set axis limits equal. Default is |
legend_title |
logical.
If |
legend_position |
character. Position of the legend. Default is |
thm |
ggplot2 theme. Specifies |
grid |
The value from calling |
grp_to_col |
character vector.
Specifies colours for elements in |
abline |
logical. If |
smooth |
logical. If |
smooth_method |
character. Smoothing method to pass to |
smooth_se |
logical. Whether to display 95% confidence interval for the
smooth line. Default is |
response_vec_a <- rnorm(5)
response_tbl <- data.frame(
group = rep(letters[1:3], each = 5),
response = c(
response_vec_a,
response_vec_a * 1.2 + rnorm(5, sd = 0.2),
response_vec_a * 2 + rnorm(5, sd = 2)
),
pid = rep(paste0("id_", 1:5), 3)
)
library(UtilsGGSV)
ggcorr(
data = response_tbl,
grp = "group",
y = "response",
id = "pid"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.