Learn R Programming

yamlet (version 1.2.1)

append_units.default: Append Units By Default

Description

Units attribute is wrapped in open and close, and appended to label. Result is assigned to target attribute (default: 'label'). If style is 'latex' or 'plotmath', all elements are treated as spork (as_spork) and coerced to canonical form before concatenation.

Usage

# S3 method for default
append_units(
  x,
  ...,
  open = getOption("yamlet_append_units_open", " ("),
  close = getOption("yamlet_append_units_close", ")"),
  style = getOption("yamlet_append_units_style", "plain"),
  target = getOption("yamlet_append_units_target", "label")
)

Value

same class as x, with sub-class 'latex' or 'plotmath' depending on style

Arguments

x

object

...

passed to as_latex, as_plotmath

open

character to precede units

close

character to follow units

style

one of 'plain', 'latex', or 'plotmath'

target

attribute name for appended result

See Also

Other labels: alias.data.frame(), append_units(), append_units.data.frame(), drop_title(), drop_title.decorated(), drop_title.default(), drop_title.dvec(), make_title(), make_title.decorated(), make_title.default(), make_title.dvec(), sub_units()

Examples

Run this code
library(units)
library(magrittr)
x <- 1:10
attr(x, 'label') <- 'acceleration'
units(x) <- 'm/s^2'
y <- as_units('kg')
x %>% attr('label')
x %>% append_units %>% attr('label')
y %>% attr('label')
y %>% append_units %>% attr('label')
x %>% append_units(style = 'plain')
x %>% append_units(style = 'plotmath')
x %>% append_units(style = 'latex')


Run the code above in your browser using DataLab