Learn R Programming

spork (version 0.1.1)

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. 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: as.expression.plotmath(), as_spork.character(), as_spork.factor()

Examples

Run this code
# NOT RUN {
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