sub_units | R Documentation |
Places units attribute below label attribute.
Makes the most sense for figures (style = 'plotmath'
)
and useful for tables (style = 'latex'
) in combination
with alias
. See also append_units
.
sub_units(
x,
...,
open = if (style == "plain") "\n(" else "\\n(",
close = ")",
style = "latex",
math_open = "",
math_close = "",
label_open = "$\\begin{gathered}",
label_close = "\\end{gathered}$",
newline = "\\\\"
)
x |
object |
... |
passed to |
open |
character to precede units |
close |
character to follow units |
style |
one of 'plain', 'latex', or 'plotmath' |
math_open, math_close, label_open, label_close, newline |
passed to |
see methods for append_units
Other labels:
alias.data.frame()
,
append_units.data.frame()
,
append_units.default()
,
append_units()
,
drop_title.decorated()
,
drop_title.default()
,
drop_title.dvec()
,
drop_title()
,
make_title.decorated()
,
make_title.default()
,
make_title.dvec()
,
make_title()
library(units)
library(magrittr)
library(dplyr)
library(ggplot2)
x <- 1:10
attr(x, 'label') <- 'acceleration'
units(x) <- 'm/s^2'
y <- as_units('kg')
x %>% attr('label')
x %>% sub_units %>% attr('label')
x %>% sub_units(style = 'plotmath') %>% attr('label')
x %>% sub_units(style = 'plain') %>% attr('label') %>% writeLines
y %>% attr('label')
y %>% sub_units(style = 'plain') %>% attr('label')
x %>% sub_units(style = 'plotmath')
x %>% sub_units(style = 'latex')
file <- system.file(package = 'yamlet', 'extdata','quinidine.csv')
file %>% decorate %>% resolve %>%
sub_units(style = 'plotmath') %>%
ggplot(data = ., aes(x = time, y = conc, color = Heart)) %>%
add(geom_point())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.