chart | R Documentation |
chart()
provides a unified interface for base plots, lattice and ggplot2.
chart(data, ..., type = NULL, env = parent.frame())
## Default S3 method:
chart(
data,
specif = NULL,
formula = NULL,
mapping = NULL,
...,
type = NULL,
auto.labs = TRUE,
env = parent.frame()
)
## S3 method for class ''function''
chart(data, ..., type = NULL, auto.labs = TRUE, env = parent.frame())
## S3 method for class 'subsettable_type'
x$name
data |
The dataset (a |
... |
Further arguments. |
type |
The type of plot to produce. |
env |
The environment where to evaluated the formula. |
specif |
Specification, being either |
formula |
A formula. |
mapping |
An |
auto.labs |
Are labels (and units) automatically used for axes? |
x |
A |
name |
The value to use for the |
....
f_aes()
, ggplot()
urchin <- data.io::read("urchin_bio", package = "data.io", lang = "en")
# base R graphics
hist(urchin$height)
# ... translates to:
chart(function() hist(urchin$height))
# ... or if the expression is provided directly, specify it is a base chart
chart(hist(urchin$height), type = "base")
# ... or more concisely:
chart$base(hist(urchin$height))
# A lattice plot
histogram(~ height, data = urchin)
chart$histogram(urchin, ~ height)
# ggplot2 histogram
ggplot(urchin, aes(height)) + geom_histogram()
#... or with chart (notice similarities with lattice version)
chart(urchin, ~ height) + geom_histogram()
#chart$geom_histogram(urchin, ~ height)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.