Learn R Programming

spork (version 0.3.5)

as_spork: 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 and to html with as_html. Both plotmath and latex names of Greek letters are supported; see as_previews.spork and examples there for disambiguation.

Usage

as_spork(x, ...)

Value

spork

Arguments

x

object

...

passed arguments

See Also

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

Examples

Run this code
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)

Run the code above in your browser using DataLab