Description Usage Arguments Value Examples
View source: R/visualization-utils.R
This is a wrapper to the typical ggplot
based histogram, i.e., using
geom_histogram
. A continuous variable, x
, is required as an input.
Optionally, a by
categorical variable can be provided.
1 2 3 4 5 6 7 8 9 10 11 12 |
x |
The numeric variable that is to be histogrammed. |
data |
A data frame with at least one numeric variable (the |
by |
A categorical variable by which to group the |
position |
If the |
facet |
A character string or character vector. If provided, we
|
facet_type |
By default, this takes the value of |
bins |
The number of bins to use in the histogram. |
alpha |
The transparency to for the filled histogram bars. This is
probably only required when using |
xlab |
The label of the x-axis (defaults to the |
ylab |
The label of the y-axis (defaults to the |
A ggplot2::ggplot
object, which may be modified with further ggplot2
commands.
1 2 3 4 5 6 | histogram(x= age, data = schizophrenia, by = gender, bins = 20)
histogram(x= age, data = schizophrenia, by = gender, position = 'identity', bins = 20, alpha = 0.7)
histogram(x= age, data = schizophrenia, by = gender, position = 'dodge', bins = 20)
histogram(x = weight, bins = 20, data = ansur, facet = height_tercile)
histogram(x = weight, bins = 20, data = ansur,
facet = c(height_tercile, age_tercile), facet_type = 'grid')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.