Learn R Programming

nexus (version 0.3.0)

barplot: Barplot of Compositional Data

Description

Displays a compositional bar chart.

Usage

# S4 method for CompositionMatrix
barplot(
  height,
  ...,
  select = NULL,
  by = groups(height),
  order_columns = FALSE,
  order_rows = NULL,
  decreasing = TRUE,
  space = 0.2,
  offset = 0.025,
  color = palette_color_discrete(),
  border = NA,
  axes = TRUE,
  legend = TRUE
)

Value

barplot() is called for its side-effects: is results in a graphic being displayed (invisibly return height).

Arguments

height

A CompositionMatrix object.

...

Further parameters to be passed to graphics::barplot().

select

A vector of column indices.

by

A vector of grouping elements, as long as the variables in height.

order_columns

A logical scalar: should should columns be reorderd?

order_rows

An integer vector giving the index of the column to be used for the ordering of the data.

decreasing

A logical scalar: should the sort order of rows be increasing or decreasing?

space

A length-one numeric vector giving the the amount of space (as a fraction of the width of a bar) left between each bar (defaults to \(0.2\)).

offset

A length-one numeric vector giving the the amount of space (as a fraction) left between groups (defaults to \(0.025\)). Only used if groups is not NULL.

color

A palette function that when called with a single argument returns a character vector of colors.

border

The color to draw the borders.

axes

A logical scalar: should axes be drawn on the plot?

legend

A logical scalar: should the legend be displayed?

Author

N. Frerebeau

See Also

Other plot methods: as_graph(), hist(), plot(), plot_logratio

Examples

Run this code
## Data from Aitchison 1986
data("hongite")

## Coerce to compositional data
coda <- as_composition(hongite)

## Bar plot
barplot(coda)

## Data from Day et al. 2011
data("kommos", package = "folio")
kommos <- remove_NA(kommos, margin = 1) # Remove cases with missing values
coda <- as_composition(kommos, groups = 1) # Coerce to compositional data

## Use ceramic types for grouping
barplot(coda, order_columns = TRUE)

## Display only minor elements
barplot(coda, select = is_element_minor(coda), order_columns = TRUE)

Run the code above in your browser using DataLab