knitr::opts_chunk$set(comment = "#>", collapse = TRUE) library(jjstatsplot) data(mtcars)
This vignette demonstrates the functions designed for categorical data:
jjbarstats()
, jjpiestats()
and jjdotplotstats()
.
jjbarstats()
jjbarstats()
creates a bar chart and automatically performs a
chi-squared test to compare the distribution of two categorical
variables. The example below compares the number of cylinders (cyl
)
across transmission types (am
).
jjbarstats(data = mtcars, dep = cyl, group = am, grvar = NULL)
jjpiestats()
jjpiestats()
is similar to jjbarstats()
but displays the results as a
pie chart.
jjpiestats(data = mtcars, dep = cyl, group = am, grvar = NULL)
jjdotplotstats()
jjdotplotstats()
shows group means using a dot plot. In this example we
plot horsepower (hp
) by engine configuration (vs
).
jjdotplotstats(data = mtcars, dep = hp, group = vs, grvar = NULL)
Each function returns a results object whose plot
element contains the
ggplot2
visualisation.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.