plot_scat2: Plot one-dimensional scatterplots for 2 groups

View source: R/marginal_plot.R

plot_scat2R Documentation

Plot one-dimensional scatterplots for 2 groups

Description

plot_scat2 produces scatterplots for 2 marginal distributions. The scatterplots are jittered using geom_quasirandom.

Usage

plot_scat2(data = df, formula = obs ~ gr, xlabel = NULL, ylabel = NULL, ...)

Arguments

data

A data frame in long format. One column is a factor describing the groups; another column contains the values/observations for each group. A properly formatted data frame can be created using mkt2. Missing values are not allowed.

formula

A formula with format response variable ∼ predictor variable, where ~ (tilde) means "is modeled as a function of".

xlabel

Option to set different name - default NULL to use data frame column names.

ylabel

Option to set different name - default NULL to use data frame column names.

...

Input arguments for ggbeeswarm::geom_quasirandom

Value

A ggplot object.

Examples

# generate data
set.seed(21)
g1 <- rnorm(1000) + 6
g2 <- rnorm(1000) * 1.5 + 6

# make tibble
df <- mkt2(g1, g2)
# make scatterplots
ps <- plot_scat2(data = df,
  formula = obs ~ gr,
  xlabel = "",
  ylabel = "Scores (a.u.)",
  alpha = 1,
  shape = 21,
  colour = "grey10",
  fill = "grey90") # scatterplots
ps <- ps + coord_flip()
ps


GRousselet/rogme documentation built on Nov. 12, 2022, 4:38 a.m.