as_spork: Coerce to Spork

View source: R/spork.R

as_sporkR Documentation

Coerce to Spork

Description

Coerces to class 'spork'. Generic, with method as_spork.character. A spork is simple text expressing arbitrarily nested subscripts (x_y_z) and superscripts (x^y^z). A dot (x^y._z) explicitly terminates a group. An asterisk (*) suggests multiplication; a literal backslash followed by 'n' suggests a newline (handling differs for latex vs. plotmath). Special characters may be escaped with a backslash. Convert to plotmath with as_plotmath and to latex with as_latex. Both plotmath and latex names of Greek letters are supported; see as_previews.spork and examples there for disambiguation.

Usage

as_spork(x, ...)

Arguments

x

object

...

passed arguments

Value

spork

See Also

Other spork: [.spork(), [[.spork(), as.list.spork(), as.png.spork(), as_html.spork(), as_latex.default(), as_latex.spork(), as_plotmath.spork(), as_previews.spork(), as_spar.spork(), as_spork.character(), as_spork.factor(), as_spork.spork(), ggplot.spork()

Examples

library(ggplot2)
label <- 'one joule (Omega) ~ 1 kg*m^2./s^2'
label <- as_spork(label)
label <- as_plotmath(label)
label <- as.expression(label)
x <- data.frame(y=1:10, x=1:10)
p <- ggplot(x, aes(x, y))
p$labels$x <- label

print(p)

spork documentation built on Sept. 16, 2023, 9:06 a.m.

Related to as_spork in spork...