chart: Create charts

chartR Documentation

Create charts

Description

chart() provides a unified interface for base plots, lattice and ggplot2.

Usage

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

Arguments

data

The dataset (a data.frame or tibble, usually).

...

Further arguments.

type

The type of plot to produce.

env

The environment where to evaluated the formula.

specif

Specification, being either aes(), or a formula.

formula

A formula.

mapping

An aes() object, as for ggplot().

auto.labs

Are labels (and units) automatically used for axes?

x

A subsettable_type function.

name

The value to use for the ⁠type=⁠ argument.

Details

....

See Also

f_aes(), ggplot()

Examples

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)

SciViews/chart documentation built on June 3, 2024, 7:26 a.m.