Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Generalized Label Formatting
Version:0.3.5
Maintainer:Tim Bergsma <bergsmat@gmail.com>
Description:The 'spork' syntax describes label formatting concisely, supporting mixed nesting of subscripts and superscripts to arbitrary depth. It intends to be easy to read and write in plain text, and easy to convert to equivalent presentations in 'plotmath', 'latex', and 'html'. Greek symbols and a multiplication symbol are explicitly supported. See ?as_spork and ?as_previews.
License:GPL-3
Encoding:UTF-8
Imports:ggplot2, png, latexpdf, kableExtra
RoxygenNote:7.3.2
Suggests:testthat (≥ 2.1.0), magrittr, dplyr
NeedsCompilation:no
Packaged:2024-10-12 01:06:20 UTC; tim.bergsma
Author:Tim Bergsma [aut, cre]
Repository:CRAN
Date/Publication:2024-10-12 02:30:02 UTC

Subset Html

Description

Subsets html, retaining class.

Usage

## S3 method for class 'html'x[...]

Arguments

x

html

...

passed to next method

Value

html

See Also

Other html:[[.html(),as_html(),as_html.greek(),as_html.spar(),as_html.spork(),html2xml(),htmlToken()

Examples

x <- c(  'V_c./F',  'AUC_ss',  'C_max_ss',  'var^eta_j')x <- as_html(as_spork(x))class(x)class(x[1])

Subset Latex

Description

Subsets latex, retaining class.

Usage

## S3 method for class 'latex'x[...]

Arguments

x

latex

...

passed to next method

Value

latex

See Also

Other latex:[[.latex(),as_latex(),as_latex.default(),as_latex.greek(),as_latex.latex(),as_latex.spar(),as_latex.spork(),concatenate.latex(),latexToken()

Examples

x <- c(  'V_c./F',  'AUC_ss',  'C_max_ss',  'var^eta_j')x <- as_latex(as_spork(x))class(x)class(x[1])

Subset Plotmath

Description

Subsets plotmath, retaining class.

Usage

## S3 method for class 'plotmath'x[...]

Arguments

x

plotmath

...

passed to next method

Value

plotmath

See Also

Other plotmath:[[.plotmath(),as.expression.plotmath(),as.png.plotmath(),as_plotmath(),as_plotmath.greek(),as_plotmath.spar(),as_plotmath.spork(),concatenate.plotmath(),ggplot.plotmath(),goodToken(),plotmathToken()

Examples

x <- c(  'V_c./F',  'AUC_ss',  'C_max_ss',  'var^eta_j')x <- as_plotmath(as_spork(x))class(x)class(x[1])

Subset Spork

Description

Subsets spork, retaining class.

Usage

## S3 method for class 'spork'x[...]

Arguments

x

spork

...

passed to next method

Value

spork

See Also

Other 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(),as_spork.character(),as_spork.factor(),as_spork.spork(),ggplot.spork(),greek()

Examples

x <- c(  'V_c./F',  'AUC_ss',  'C_max_ss',  'var^eta_j')x <- as_spork(x)class(x)class(x[1])

Element-select Html

Description

Element-selects html, retaining class.

Usage

## S3 method for class 'html'x[[...]]

Arguments

x

html

...

passed to next method

Value

html

See Also

Other html:[.html(),as_html(),as_html.greek(),as_html.spar(),as_html.spork(),html2xml(),htmlToken()

Examples

x <- c(  'V_c./F',  'AUC_ss',  'C_max_ss',  'var^eta_j')x <- as_html(as_spork(x))class(x)class(x[[1]])

Element-select Latex

Description

Element-selects latex, retaining class.

Usage

## S3 method for class 'latex'x[[...]]

Arguments

x

latex

...

passed to next method

Value

latex

See Also

Other latex:[.latex(),as_latex(),as_latex.default(),as_latex.greek(),as_latex.latex(),as_latex.spar(),as_latex.spork(),concatenate.latex(),latexToken()

Examples

x <- c(  'V_c./F',  'AUC_ss',  'C_max_ss',  'var^eta_j')x <- as_latex(as_spork(x))class(x)class(x[[1]])

Element-select Plotmath

Description

Element-selects plotmath, retaining class.

Usage

## S3 method for class 'plotmath'x[[...]]

Arguments

x

plotmath

...

passed to next method

Value

plotmath

See Also

Other plotmath:[.plotmath(),as.expression.plotmath(),as.png.plotmath(),as_plotmath(),as_plotmath.greek(),as_plotmath.spar(),as_plotmath.spork(),concatenate.plotmath(),ggplot.plotmath(),goodToken(),plotmathToken()

Examples

x <- c(  'V_c./F',  'AUC_ss',  'C_max_ss',  'var^eta_j')x <- as_plotmath(as_spork(x))class(x)class(x[[1]])

Element-select Spork

Description

Element-selects spork, retaining class.

Usage

## S3 method for class 'spork'x[[...]]

Arguments

x

spork

...

passed to next method

Value

spork

See Also

Other 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(),as_spork.character(),as_spork.factor(),as_spork.spork(),ggplot.spork(),greek()

Examples

x <- c(  'V_c./F',  'AUC_ss',  'C_max_ss',  'var^eta_j')x <- as_spork(x)class(x)class(x[[1]])

Coerce Plotmath to Expression

Description

Coerces plotmath to expression by parsing as text.

Usage

## S3 method for class 'plotmath'as.expression(x, ...)

Arguments

x

plotmath

...

ignored arguments

Value

expression

See Also

Other interface:as_html.spar(),as_html.spork(),as_latex.spar(),as_latex.spork(),as_plotmath.spar(),as_plotmath.spork(),as_previews.spork(),as_spork.character(),htmlToken(),latexToken(),plotmathToken()

Other plotmath:[.plotmath(),[[.plotmath(),as.png.plotmath(),as_plotmath(),as_plotmath.greek(),as_plotmath.spar(),as_plotmath.spork(),concatenate.plotmath(),ggplot.plotmath(),goodToken(),plotmathToken()

Examples

x <- c(  'V_c./F',  'AUC_ss',  'C_max_ss',  'var^eta_j')x <- as_spork(x)x <- as_plotmath(x)xas.expression(x)[[4]]as.expression(x[[4]])class(as.expression(x))lapply(as.expression(x), class)as.expression(as_plotmath(as_spork('V_c./F')))as.expression(as_plotmath(as_spork(character(0))))library(magrittr)'gravitational force (kg\\.m/s^2.)' %>%  as_spork %>%  as_plotmath %>%  as.expression -> label  label

Coerce Spork to List

Description

Coerces spork to list. Each element inherits class.Supports use oflapply.

Usage

## S3 method for class 'spork'as.list(x, ...)

Arguments

x

spork

...

ignored

Value

list of spork

See Also

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

Examples

x <- as_spork(letters[1:5])lapply(x, class)

Convert Plotmath to PNG

Description

Converts plotmath to png.

Usage

## S3 method for class 'plotmath'as.png(  x,  filename = tempfile(),  width = 3,  height = 1,  units = "in",  res = 150,  ...)

Arguments

x

plotmath; seeas_plotmath

filename

path for image file

width

width

height

height

units

units

res

resolution

...

passed arguments

Value

invisible filepath

See Also

Other preview:as.png.spork(),as_preview(),as_preview.html(),as_preview.latex(),as_preview.plotmath(),as_previews(),as_previews.default(),as_previews.spork(),ggplot.plotmath(),ggplot.spork()

Other png:as.png.spork()

Other plotmath:[.plotmath(),[[.plotmath(),as.expression.plotmath(),as_plotmath(),as_plotmath.greek(),as_plotmath.spar(),as_plotmath.spork(),concatenate.plotmath(),ggplot.plotmath(),goodToken(),plotmathToken()

Examples

library(magrittr)library(latexpdf)'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_plotmath %>% as.png -> filefile

Convert Spork to PNG

Description

Converts spork to png.

Usage

## S3 method for class 'spork'as.png(  x,  filename = tempfile(),  width = 3,  height = 1,  units = "in",  res = 150,  ...)

Arguments

x

spork; seeas_spork

filename

path for image file

width

width

height

height

units

units

res

resolution

...

passed arguments

Value

invisible filepath

See Also

Other preview:as.png.plotmath(),as_preview(),as_preview.html(),as_preview.latex(),as_preview.plotmath(),as_previews(),as_previews.default(),as_previews.spork(),ggplot.plotmath(),ggplot.spork()

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

Other png:as.png.plotmath()

Examples

library(magrittr)library(latexpdf)'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as.png -> filefile

Convert to Greek

Description

Converts to Greek. Generic, with method for character.

Usage

as_greek(x, ...)

Arguments

x

object of dispatch

...

passed arguments

See Also

Other greek:as_greek.default()


Convert character to Greek

Description

Converts character to Greek by assigning class 'greek'.

Usage

## Default S3 method:as_greek(x, ...)

Arguments

x

coerced to character

...

passed arguments

Value

class greek (character)

See Also

Other greek:as_greek()

Examples

as_greek(greek())

Coerce to Html

Description

Coerce to html. Generic, with methodas_html.spork.

Usage

as_html(x, ...)

Arguments

x

object

...

passed arguments

Value

html

See Also

Other html:[.html(),[[.html(),as_html.greek(),as_html.spar(),as_html.spork(),html2xml(),htmlToken()

Examples

example(as_html.spork)

Convert Greek to Html

Description

Converts Greek letter names to html.

Usage

## S3 method for class 'greek'as_html(x, ...)

Arguments

x

greek

...

ignored

Value

html

See Also

Other html:[.html(),[[.html(),as_html(),as_html.spar(),as_html.spork(),html2xml(),htmlToken()

Examples

as_html(greek())

Convert One Spork to Html

Description

Converts one spork to html.See description foras_spork.By default, unrecognized tokens are returnedliterally. However, Greek symbols and htmlmetacharacters are escaped.SeehtmlToken.

Usage

## S3 method for class 'spar'as_html(  x,  newline = getOption("html_newline", "<br/>"),  unrecognized = getOption("html_unrecognized", spork::htmlToken),  token_open = getOption("html_token_open", ""),  token_close = getOption("html_token_close", ""),  math_open = getOption("html_math_open", ""),  math_close = getOption("html_math_close", ""),  label_open = getOption("html_label_open", ""),  label_close = getOption("html_label_close", ""),  ...)

Arguments

x

spar

newline

value to replace'\n'

unrecognized

function to process unrecognized tokens: defaulthtmlToken

token_open,token_close

these wrap text-like portions of the label; the defaults try to give upright characters (non-italic); also passed tohtmlToken

math_open,math_close

these wrap math-like portions of the label; the defaults try to give upright characters (non-italic) which may not work for Greek symbols; also passed tohtmlToken

label_open,label_close

these wrap the entire label

...

passed tounrecognized; seehtmlToken

Details

Experimental support is implemented forthe newline character ('\n').Default behavior is to introduce linebreaks(<br/>) into the resultinghtml.

Value

html

See Also

Other interface:as.expression.plotmath(),as_html.spork(),as_latex.spar(),as_latex.spork(),as_plotmath.spar(),as_plotmath.spork(),as_previews.spork(),as_spork.character(),htmlToken(),latexToken(),plotmathToken()

Other html:[.html(),[[.html(),as_html(),as_html.greek(),as_html.spork(),html2xml(),htmlToken()

Examples

library(magrittr)'V_c./F' %>% as_spork %>% as_html'AUC_ss' %>% as_spork %>% as_html'C_max_ss' %>% as_spork %>% as_html'var^eta_j' %>% as_spork %>% as_html'& < % $ # \\_ { } ~ \\^ \\' %>% as_spork %>% as_html'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_html'one joule (`Omega`) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_html'one joule (\\`Omega\\`) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_html

Convert Spork to Html

Description

Converts spork to html.Vectorized version ofas_html.spar.

Usage

## S3 method for class 'spork'as_html(x, ...)

Arguments

x

spork

...

passed toas_html.spar

Value

html

See Also

Other html:[.html(),[[.html(),as_html(),as_html.greek(),as_html.spar(),html2xml(),htmlToken()

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

Other interface:as.expression.plotmath(),as_html.spar(),as_latex.spar(),as_latex.spork(),as_plotmath.spar(),as_plotmath.spork(),as_previews.spork(),as_spork.character(),htmlToken(),latexToken(),plotmathToken()

Examples

x <- c(  'V_c./F',  'AUC_ss',  'C_max_ss',  'var^eta_j')x <- as_spork(x)as_html(x)as_html(as_spork('gravitational force (kg\\.m/s^2.)'))

Coerce to Latex

Description

Coerce to latex. Generic, with methodas_latex.spork.

Usage

as_latex(x, ...)

Arguments

x

object

...

passed arguments

Value

latex

See Also

Other latex:[.latex(),[[.latex(),as_latex.default(),as_latex.greek(),as_latex.latex(),as_latex.spar(),as_latex.spork(),concatenate.latex(),latexToken()

Examples

example(as_latex.spork)

Coerce Default to Latex

Description

Coerces non-latex to 'latex'. Simply prepends 'latex' to class path.

Usage

## Default S3 method:as_latex(x, ...)

Arguments

x

presumably inherits character

...

ignored

Value

latex

See Also

Other latex:[.latex(),[[.latex(),as_latex(),as_latex.greek(),as_latex.latex(),as_latex.spar(),as_latex.spork(),concatenate.latex(),latexToken()

Examples

class(as_latex(letters))

Convert Greek to Latex

Description

Converts Greek letter names to latex.By default, assumes latex packageupgreek is availableso that lower case greek can be typeset upright, e.g. using backslash-upalpha instead of backslash-alpha. Do use the package"upgreek" in your document preamble,or else in your R environment setoptions(spork_upgreek = FALSE).

Usage

## S3 method for class 'greek'as_latex(x, ..., upgreek = getOption("spork_upgreek", TRUE))

Arguments

x

greek

...

ignored,

upgreek

if TRUE, assume latex packageupgreek is available

Value

latex

See Also

Other latex:[.latex(),[[.latex(),as_latex(),as_latex.default(),as_latex.latex(),as_latex.spar(),as_latex.spork(),concatenate.latex(),latexToken()

Examples

as_latex(greek())

Coerce Latex to Latex

Description

Coerces class 'latex' to 'latex'. Simply returns x.

Usage

## S3 method for class 'latex'as_latex(x, ...)

Arguments

x

latex

...

ignored

Value

latex

See Also

Other latex:[.latex(),[[.latex(),as_latex(),as_latex.default(),as_latex.greek(),as_latex.spar(),as_latex.spork(),concatenate.latex(),latexToken()

Examples

class(as_latex(as_latex(letters)))

Convert One Spork to Latex

Description

Converts one spork to latex.See description foras_spork.By default, unrecognized tokens are returnedliterally. However, Greek symbols and latexmetacharacters are escaped.SeelatexToken.

Usage

## S3 method for class 'spar'as_latex(  x,  newline = getOption("latex_newline", "\n"),  unrecognized = getOption("latex_unrecognized", spork::latexToken),  token_open = getOption("latex_token_open", "\\textrm{"),  token_close = getOption("latex_token_close", "}"),  math_open = getOption("latex_math_open", "\\mathrm{"),  math_close = getOption("latex_math_close", "}"),  label_open = getOption("latex_label_open", "\\("),  label_close = getOption("latex_label_close", "\\)"),  enforce_math = getOption("latex_enforce_math", TRUE),  script_size = getOption("latex_script_size", c("", "\\scriptsize ", "\\tiny ")),  ...)

Arguments

x

spar

newline

value to replace'\n'

unrecognized

function to process unrecognized tokens: defaultlatexToken

token_open,token_close

these wrap text-like portions of the label; the defaults try to give upright characters (non-italic); also passed tolatexToken

math_open,math_close

these wrap math-like portions of the label; the defaults try to give upright characters (non-italic) which may not work for Greek symbols; also passed tolatexToken

label_open,label_close

these wrap the entire label; defaults invoke traditional math mode

enforce_math

whether to enforce math mode for nested expression:latexToken

script_size

three character values, one of which will be appended to token_open for unnested, nested, and multiply-nested contexts

...

passed tounrecognized; seelatexToken

Details

Experimental support is implemented forthe newline character ('\n').Default behavior is to introduce literalnewline characters into the resultingtex. This may have no effect on thetypeset result. It may be possibleto achieve other effects by usingnon-default values of helper argumentsand perhaps additional latex packages.

Value

latex

See Also

Other interface:as.expression.plotmath(),as_html.spar(),as_html.spork(),as_latex.spork(),as_plotmath.spar(),as_plotmath.spork(),as_previews.spork(),as_spork.character(),htmlToken(),latexToken(),plotmathToken()

Other latex:[.latex(),[[.latex(),as_latex(),as_latex.default(),as_latex.greek(),as_latex.latex(),as_latex.spork(),concatenate.latex(),latexToken()

Examples

library(magrittr)'V_c./F' %>% as_spork %>% as_latex'AUC_ss' %>% as_spork %>% as_latex'C_max_ss' %>% as_spork %>% as_latex'var^eta_j' %>% as_spork %>% as_latex'& % $ # \\_ { } ~ \\^ \\' %>% as_spork %>% as_latex'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_latex'one joule (`Omega`) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_latex'one joule (\\`Omega\\`) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_latex

Convert Spork to Latex

Description

Converts spork to latex.Vectorized version ofas_latex.spar.

Usage

## S3 method for class 'spork'as_latex(x, ...)

Arguments

x

spork

...

passed toas_latex.spar

Value

latex

See Also

Other latex:[.latex(),[[.latex(),as_latex(),as_latex.default(),as_latex.greek(),as_latex.latex(),as_latex.spar(),concatenate.latex(),latexToken()

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

Other interface:as.expression.plotmath(),as_html.spar(),as_html.spork(),as_latex.spar(),as_plotmath.spar(),as_plotmath.spork(),as_previews.spork(),as_spork.character(),htmlToken(),latexToken(),plotmathToken()

Examples

x <- c(  'V_c./F',  '\\nAUC_ss',  'C_max_ss\\n',  'var^eta_j\\nrecords')x <- as_spork(x)writeLines(as_latex(x))x <- as_spork('gravitational force\\n (kg\\.m/s^2.)')explicit(x)as_latex(x)

Coerce to Plotmath

Description

Coerce to plotmath. Generic, with methodas_plotmath.spork.

Usage

as_plotmath(x, ...)

Arguments

x

object

...

passed arguments

Value

plotmath

See Also

Other plotmath:[.plotmath(),[[.plotmath(),as.expression.plotmath(),as.png.plotmath(),as_plotmath.greek(),as_plotmath.spar(),as_plotmath.spork(),concatenate.plotmath(),ggplot.plotmath(),goodToken(),plotmathToken()

Examples

example(as_plotmath.spork)

Convert Greek to Plotmath

Description

Converts Greek letter names to plotmath.

Usage

## S3 method for class 'greek'as_plotmath(x, ...)

Arguments

x

greek

...

ignored

Value

plotmath

See Also

Other plotmath:[.plotmath(),[[.plotmath(),as.expression.plotmath(),as.png.plotmath(),as_plotmath(),as_plotmath.spar(),as_plotmath.spork(),concatenate.plotmath(),ggplot.plotmath(),goodToken(),plotmathToken()

Examples

as_plotmath(greek())

Convert One Spork to Plotmath

Description

Converts one spork to plotmath.See description foras_spork.Unrecognized tokens are returnedunmodified by default.Otherwise, backslashes and single quotes are escaped,and the result is wrapped in single quotes.SeeplotmathToken.

Usage

## S3 method for class 'spar'as_plotmath(  x,  unrecognized = getOption("plotmath_unrecognized", spork::plotmathToken),  ...)

Arguments

x

spar

unrecognized

function to process unrecognized tokens

...

passed tounrecognized

Details

Experimental support is implemented forthe sequence "backslash n" ('\n').It tries to break the expression at thepoint indicated, and stack the results.Active subscripts and superscriptsare closed in advance, preventingthese from breaking across lines.

Value

character

See Also

plotmathToken

Other interface:as.expression.plotmath(),as_html.spar(),as_html.spork(),as_latex.spar(),as_latex.spork(),as_plotmath.spork(),as_previews.spork(),as_spork.character(),htmlToken(),latexToken(),plotmathToken()

Other plotmath:[.plotmath(),[[.plotmath(),as.expression.plotmath(),as.png.plotmath(),as_plotmath(),as_plotmath.greek(),as_plotmath.spork(),concatenate.plotmath(),ggplot.plotmath(),goodToken(),plotmathToken()

Other spar:as_spar(),as_spar.default(),as_spar.spork()

Examples

library(magrittr)'V_c./F' %>% as_spork %>% as_plotmath'AUC_ss' %>% as_spork %>% as_plotmath'C_max_ss' %>% as_spork %>% as_plotmath'var^eta_j' %>% as_spork %>% as_plotmath'& % $ # \\_ { } ~ \\^ \\' %>% as_spork %>% as_plotmath'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_plotmath'one joule (`Omega`) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_plotmath'one joule (\\`Omega\\`) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_plotmath

Convert Spork to Plotmath

Description

Converts spork to plotmath. Seeplotmath.Vectorized version ofas_plotmath.spar.

Usage

## S3 method for class 'spork'as_plotmath(x, ...)

Arguments

x

spork

...

passed toas_plotmath.spar

Value

plotmath

See Also

Other plotmath:[.plotmath(),[[.plotmath(),as.expression.plotmath(),as.png.plotmath(),as_plotmath(),as_plotmath.greek(),as_plotmath.spar(),concatenate.plotmath(),ggplot.plotmath(),goodToken(),plotmathToken()

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

Other interface:as.expression.plotmath(),as_html.spar(),as_html.spork(),as_latex.spar(),as_latex.spork(),as_plotmath.spar(),as_previews.spork(),as_spork.character(),htmlToken(),latexToken(),plotmathToken()

Examples

library(magrittr)'V_c./F' %>% as_spork %>% as_plotmath'AUC_ss' %>% as_spork %>% as_plotmath'C_max_ss' %>% as_spork %>% as_plotmath'var^eta_j' %>% as_spork %>% as_plotmath'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_plotmath

Preview Something

Description

Creates a preview.Generic, with methodsas_preview.latex andas_preview.plotmath.

Usage

as_preview(x, ...)

Arguments

x

object

...

passed arguments

Value

see methods

See Also

Other preview:as.png.plotmath(),as.png.spork(),as_preview.html(),as_preview.latex(),as_preview.plotmath(),as_previews(),as_previews.default(),as_previews.spork(),ggplot.plotmath(),ggplot.spork()

Examples

library(magrittr)'V_c./F' %>% as_spork %>% as_plotmath %>% as_preview# 'V_c./F' %>% as_spork %>% as_latex %>% as_preview'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_plotmath %>% as_preview# 'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_latex %>% as_preview

Preview Spork as Html

Description

Preview spork after conversion to htmlInvokes the viewer using the print method for class 'kableExtra'.

Usage

## S3 method for class 'html'as_preview(x, ...)

Arguments

x

spork; seeas_spork

...

ignored arguments

Value

kableExtra

See Also

Other preview:as.png.plotmath(),as.png.spork(),as_preview(),as_preview.latex(),as_preview.plotmath(),as_previews(),as_previews.default(),as_previews.spork(),ggplot.plotmath(),ggplot.spork()

Examples

library(magrittr)'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>%as_html %>% as_preview

Preview Spork as Latex

Description

Preview spork after conversion to latex.Creates and displays a temporary png file, afterconversion from pdf usingghostconvert.

Usage

## S3 method for class 'latex'as_preview(  x,  wide = 70,  long = 20,  stem = "latex_preview",  dir = tempdir(),  gs_cmd = getOption("gs_cmd", "mgs"),  morePreamble = ifelse(getOption("spork_upgreek", TRUE), "\\usepackage{upgreek}\n",    NULL),  prolog = "\\begin{center}",  epilog = "\\end{center}",  ...)

Arguments

x

spork; seeas_spork

wide

nominal page width

long

nominal page length

dir

a working directory; seeas.pdf

gs_cmd

ghostscript command; seeghostconvert

morePreamble

additional text to insert in preamble; passed toas.pdf

prolog

passed toas.document

epilog

passed toas.document

...

passed arguments

Value

invisible filepath

See Also

Other preview:as.png.plotmath(),as.png.spork(),as_preview(),as_preview.html(),as_preview.plotmath(),as_previews(),as_previews.default(),as_previews.spork(),ggplot.plotmath(),ggplot.spork()

Examples

# library(magrittr)# 'one joule (Omega) ~ 1 kg*m^2./s^2' %>%# as_spork %>%# as_latex %>%#as_preview

Preview Spork as Plotmath

Description

Preview spork after conversion to plotmath.Creates and displays a temporary png file witha parsed expression.

Usage

## S3 method for class 'plotmath'as_preview(x, stem = "plotmath_preview", width = 3, height = 1, ...)

Arguments

x

spork; seeas_spork

width

passed toas.png.plotmath

height

passed toas.png.plotmath

...

passed arguments

Value

invisible filepath

See Also

Other preview:as.png.plotmath(),as.png.spork(),as_preview(),as_preview.html(),as_preview.latex(),as_previews(),as_previews.default(),as_previews.spork(),ggplot.plotmath(),ggplot.spork()

Examples

library(magrittr)'one joule (Omega) ~ 1 kg*m^2./s^2' %>%as_spork %>%as_plotmath %>%as_preview

Compare Previews

Description

Compare previews of something.Generic, with methodas_previews.spork.

Usage

as_previews(x, ...)

Arguments

x

object

...

passed arguments

Value

see methods

See Also

Other preview:as.png.plotmath(),as.png.spork(),as_preview(),as_preview.html(),as_preview.latex(),as_preview.plotmath(),as_previews.default(),as_previews.spork(),ggplot.plotmath(),ggplot.spork()

Examples

example(as_previews.spork)

Default Compare Previews

Description

Compare previews by default assuming input is spork..

Usage

## Default S3 method:as_previews(x, ...)

Arguments

x

character

...

passed arguments

Value

see as_previews.spork

See Also

Other preview:as.png.plotmath(),as.png.spork(),as_preview(),as_preview.html(),as_preview.latex(),as_preview.plotmath(),as_previews(),as_previews.spork(),ggplot.plotmath(),ggplot.spork()

Examples

example(as_previews.spork)

Compare Previews of Spork

Description

Compares plotmath and latex previews of sporkGenerates png for both, and overlayslatex above plotmath.

Usage

## S3 method for class 'spork'as_previews(x, wide = 70, long = 20, width = 3, height = 1, sleep = 2, ...)

Arguments

x

length-one spork

wide

width in mm of the latex image

long

length in mm of the latex image

width

width (default: inches) of the plotmath image

height

height (default: inches) of the plotmath image

sleep

how long to pause after html before latex/plotmath

...

passed arguments

Value

invisible list of filepaths

See Also

Other preview:as.png.plotmath(),as.png.spork(),as_preview(),as_preview.html(),as_preview.latex(),as_preview.plotmath(),as_previews(),as_previews.default(),ggplot.plotmath(),ggplot.spork()

Other interface:as.expression.plotmath(),as_html.spar(),as_html.spork(),as_latex.spar(),as_latex.spork(),as_plotmath.spar(),as_plotmath.spork(),as_spork.character(),htmlToken(),latexToken(),plotmathToken()

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

Examples

library(magrittr)specials <- '& % $ # \\_ { } ~ \\^ \\'# specials %>% as_spork %>% as_previews# specials %>% gsub(' ','',.) %>% as_spork %>% as_previews# 'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_previews# disambiguation for plotmath and latex (see \code{\link[grDevices]{plotmath}}):# 'epsilon.varepsilon' %>% as_spork %>% as_previews# 'rho.varrho' %>% as_spork %>% as_previews# 'Upsilon.Upsilon1' %>% as_spork %>% as_previews# 'phi.phi1.varphi' %>% as_spork %>% as_previews# 'sigma.sigma1.varsigma.stigma' %>% as_spork %>% as_previews# 'theta.vartheta.theta1' %>% as_spork %>% as_previews# 'omega.omega1.pi.varpi' %>% as_spork %>% as_previews

Parse Spork.

Description

Parses spork.Generic, with methodas_spar.spork.

Usage

as_spar(x, ...)

Arguments

x

object

...

passed arguments

Value

see methods

See Also

Other spar:as_plotmath.spar(),as_spar.default(),as_spar.spork()

Examples

# see methods

Parse Spork by Default

Description

Parses spork by default. Coerces input withas_spork().

Usage

## Default S3 method:as_spar(x, ...)

Arguments

x

length-one character using spork syntax

...

ignored arguments

Value

spar (character vector)

See Also

Other spar:as_plotmath.spar(),as_spar(),as_spar.spork()

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


Parse Spork

Description

Parses spork. Converts length-one characterto vector of tokens. Explicit tokens include*._^ and any of these escaped withbackslash, e.g.'\*'.Backslash-n is an explicit token ('\n').Backslash-backtick is an explicit token ('\`').One or more consecutive whitespace characters are a single token,as are one or more consecutive octothorpes (#).Any string of characters delimited byone or more of the above is implicitlya token as well. As of version 0.2.6,supported names of Greek letters are tokens (seegreek) possiblybounded by backticks (to be interpreted literally).

Usage

## S3 method for class 'spork'as_spar(x, ...)

Arguments

x

length-one character using spork syntax

...

ignored arguments

Value

spar (character vector)

See Also

Other spar:as_plotmath.spar(),as_spar(),as_spar.default()

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_spork(),as_spork.character(),as_spork.factor(),as_spork.spork(),ggplot.spork(),greek()

Examples

as_spar(as_spork('one joule (Omega) ~ 1 kg*m^2./s^2'))as_spar(as_spork('one joule (`Omega`) ~ 1 kg*m^2./s^2'))as_spar(as_spork('one joule (\\`Omega\\`) ~ 1 kg*m^2./s^2'))

Coerce to Spork

Description

Coerces to class 'spork'. Generic,with methodas_spork.character.A spork is simple text expressingarbitrarily nested subscripts (x_y_z)and superscripts (x^y^z). A dot(x^y._z) explicitly terminatesa group. An asterisk (*) suggestsmultiplication; a literal backslashfollowed by 'n' suggests a newline(handling differs for latex vs. plotmath).Special characters may be escaped with a backslash.Convert to plotmath withas_plotmathand to latex withas_latexand to html withas_html.Both plotmath and latex names of Greekletters are supported; seeas_previews.sporkand 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.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

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 <- labelprint(p)

Coerce Character to Spork

Description

Coerces character to class 'spork'.See description foras_spork.

Usage

## S3 method for class 'character'as_spork(x, ...)

Arguments

x

character

...

ignored arguments

Value

spork

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(),as_spork.factor(),as_spork.spork(),ggplot.spork(),greek()

Other interface:as.expression.plotmath(),as_html.spar(),as_html.spork(),as_latex.spar(),as_latex.spork(),as_plotmath.spar(),as_plotmath.spork(),as_previews.spork(),htmlToken(),latexToken(),plotmathToken()

Other character:concatenate.character()

Examples

as_spork('V_c./F')

Coerce Factor to Spork

Description

Coerces factor to class 'spork'by converting to character and callingas_spork.

Usage

## S3 method for class 'factor'as_spork(x, ...)

Arguments

x

factor

...

ignored arguments

Value

spork

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(),as_spork.character(),as_spork.spork(),ggplot.spork(),greek()

Examples

as_spork(as.factor('V_c./F'))

Coerce Spork to Spork

Description

Coerces 'spork' to class 'spork'.Supplies any implied terminal dots.

Usage

## S3 method for class 'spork'as_spork(x, ...)

Arguments

x

spork

...

ignored arguments

Value

spork

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(),as_spork.character(),as_spork.factor(),ggplot.spork(),greek()

Examples

as_spork(as_spork(c('C_max_ss','t^1/2','V_c./F','foo')))as_spork(as_spork('V_c./F'))as_spork(as_spork('V_c'))

Concatenate Something

Description

Concatenates something.Generic, with methodsconcatenate.character,concatenate.plotmath, andconcatenate.latex.

Usage

concatenate(x, ...)

Arguments

x

object

...

passed arguments

Value

see methods

See Also

Other concatenate:concatenate.NULL(),concatenate.character(),concatenate.latex(),concatenate.plotmath()

Examples

# see methods

Concatenate NULL

Description

Concatenates null. Returns empty string.

Usage

## S3 method for class ''NULL''concatenate(x, ...)

Arguments

x

NULL

...

passed arguments

Value

character

See Also

Other concatenate:concatenate(),concatenate.character(),concatenate.latex(),concatenate.plotmath()

Examples

concatenate(NULL)

Concatenate Character

Description

Concatenates Character. Collapses vector using separator.

Usage

## S3 method for class 'character'concatenate(x, sep = "", ...)

Arguments

x

character

sep

character

...

passed arguments

Value

character

See Also

Other concatenate:concatenate(),concatenate.NULL(),concatenate.latex(),concatenate.plotmath()

Other character:as_spork.character()

Examples

concatenate(letters)

Concatenate Latex

Description

Concatenates latex. Collapses vector using separator.

Usage

## S3 method for class 'latex'concatenate(x, sep = "{}", ...)

Arguments

x

latex

sep

character

...

passed arguments

Value

latex

See Also

Other concatenate:concatenate(),concatenate.NULL(),concatenate.character(),concatenate.plotmath()

Other latex:[.latex(),[[.latex(),as_latex(),as_latex.default(),as_latex.greek(),as_latex.latex(),as_latex.spar(),as_latex.spork(),latexToken()

Examples

concatenate(as_latex(as_spork(c('BMI_i','kg/m^2'))))

Concatenate Plotmath

Description

Concatenates plotmath. Collapses vector using separator.

Usage

## S3 method for class 'plotmath'concatenate(x, sep = "*", ...)

Arguments

x

plotmath

sep

character

...

passed arguments

Value

plotmath

See Also

Other concatenate:concatenate(),concatenate.NULL(),concatenate.character(),concatenate.latex()

Other plotmath:[.plotmath(),[[.plotmath(),as.expression.plotmath(),as.png.plotmath(),as_plotmath(),as_plotmath.greek(),as_plotmath.spar(),as_plotmath.spork(),ggplot.plotmath(),goodToken(),plotmathToken()

Examples

concatenate(as_plotmath(as_spork(c('BMI_i','kg/m^2'))))

Make Something Explicit

Description

Makes something explicit.Generic, with methodexplicit.spork.

Usage

explicit(x, ...)

Arguments

x

object

...

passed arguments

Value

see methods

See Also

Other explicit:explicit.spork()

Examples

# see methods

Make Spork Explicit

Description

Makes spork explicit. For every sectionas indicated by line breaks, it suppliesdots to close open scripts.Explicit spork can be concatenated more easily.One generally wants to avoid breaking lineswithin active sub- and super scripts.

Usage

## S3 method for class 'spork'explicit(x, ...)

Arguments

x

character

...

passed arguments

Value

spork

See Also

Other explicit:explicit()

Examples

s <- c(  'Work_out\\nx^y\\n',  '\\nkg/m^2/S^2')explicit(as_spork(s))

Plot Plotmath

Description

Render plotmath in a ggplot.

Usage

## S3 method for class 'plotmath'ggplot(data, mapping = aes(), ..., environment = parent.frame(), blank = TRUE)

Arguments

data

length-one plotmath; seeas_plotmath

mapping

ignored

...

ignored arguments

environment

ignored

blank

whether to use a blank plot area

Value

gg

See Also

Other preview:as.png.plotmath(),as.png.spork(),as_preview(),as_preview.html(),as_preview.latex(),as_preview.plotmath(),as_previews(),as_previews.default(),as_previews.spork(),ggplot.spork()

Other ggplot:ggplot.spork()

Other plotmath:[.plotmath(),[[.plotmath(),as.expression.plotmath(),as.png.plotmath(),as_plotmath(),as_plotmath.greek(),as_plotmath.spar(),as_plotmath.spork(),concatenate.plotmath(),goodToken(),plotmathToken()

Examples

library(magrittr)'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% as_plotmath %>% ggplot

Plot Spork

Description

Render spork in a ggplot.

Usage

## S3 method for class 'spork'ggplot(data, mapping = aes(), ..., environment = parent.frame(), blank = TRUE)

Arguments

data

length-one spork; seeas_spork

mapping

ignored

...

ignored arguments

environment

ignored

blank

whether to use a blank plot area

Value

gg

See Also

Other preview:as.png.plotmath(),as.png.spork(),as_preview(),as_preview.html(),as_preview.latex(),as_preview.plotmath(),as_previews(),as_previews.default(),as_previews.spork(),ggplot.plotmath()

Other ggplot:ggplot.plotmath()

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(),as_spork.character(),as_spork.factor(),as_spork.spork(),greek()

Examples

library(magrittr)'one joule (Omega) ~ 1 kg*m^2./s^2' %>% as_spork %>% ggplot

Test Whether Token is Parseable

Description

Tests whether token is Parseable

Usage

goodToken(x, ...)

Arguments

x

length-one character

...

ignored arguments

Value

logical

See Also

Other plotmath:[.plotmath(),[[.plotmath(),as.expression.plotmath(),as.png.plotmath(),as_plotmath(),as_plotmath.greek(),as_plotmath.spar(),as_plotmath.spork(),concatenate.plotmath(),ggplot.plotmath(),plotmathToken()

Examples

goodToken('alpha')goodToken('foo')goodToken('\\$')

Greek letters recognized by Spork

Description

Returns words representing the Greekletters recognized byspork.

Usage

greek()

Details

Seeplotmath for related detail.In addition to the 24 uppercase and 24lowercase Greek letters, latex supports varepsilon, vartheta, varpi, varsigma, and varrhowhile plotmath supportstheta1, phi1, sigma1, omega1, Upsilon1, and stigma1.Spork supports all, and tries to do something usefulfor those not supported in html, latex, or plotmath.

Value

class 'greek' (character)

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(),as_spork.character(),as_spork.factor(),as_spork.spork(),ggplot.spork()

Examples

greek()

Convert HTML Greek entity references to XML

Description

Converts HTML Greek entity references to XML entity references.This is necessary because of a kableExtra bug: https://github.com/haozhu233/kableExtra/issues/814 .The mappings used here are from https://www.thoughtco.com/html-codes-greek-characters-4062212

Usage

html2xml(x, ...)

Arguments

x

html character

...

ignored

Value

html

See Also

Other html:[.html(),[[.html(),as_html(),as_html.greek(),as_html.spar(),as_html.spork(),htmlToken()

Examples

htmlToken('alpha')htmlToken('Upsilon1')htmlToken('vartheta')htmlToken('stigma')htmlToken('varrho')htmlToken('varpi')htmlToken('Upsilon1')

Process Html Token

Description

Pre-processes a html token not recognized asspork. Escapes the common names for Greek lettersand escapes html metacharacters.

Usage

htmlToken(  x,  token_open = getOption("html_token_open", ""),  token_close = getOption("html_token_close", ""),  math_open = getOption("html_math_open", ""),  math_close = getOption("html_math_close", ""),  label_open = getOption("html_label_open", ""),  label_close = getOption("html_label_close", ""),  ...)

Arguments

x

character

token_open,token_close

these wrap the entire token (used once); by default the token is text-like

math_open,math_close

these wrap math-like portions of the token; the defaults try to give upright characters (non-italic) which may not work for Greek symbols

label_open,label_close

these re-wrap math-like portions of the token

...

ignored arguments

Value

html

See Also

Other html:[.html(),[[.html(),as_html(),as_html.greek(),as_html.spar(),as_html.spork(),html2xml()

Other interface:as.expression.plotmath(),as_html.spar(),as_html.spork(),as_latex.spar(),as_latex.spork(),as_plotmath.spar(),as_plotmath.spork(),as_previews.spork(),as_spork.character(),latexToken(),plotmathToken()

Examples

htmlToken('foo')htmlToken('alpha')htmlToken('Alpha')

Process Latex Token

Description

Pre-processes a latex token not recognized asspork. Escapes the common names for Greek lettersand escapes latex metacharacters.

Usage

latexToken(  x,  token_open = getOption("latex_token_open", "\\textrm{"),  token_close = getOption("latex_token_close", "}"),  math_open = getOption("latex_math_open", "\\mathrm{"),  math_close = getOption("latex_math_close", "}"),  label_open = getOption("latex_label_open", "\\("),  label_close = getOption("latex_label_close", "\\)"),  enforce_math = getOption("latex_enforce_math", TRUE),  ...)

Arguments

x

character

token_open,token_close

these wrap the entire token (used once); by default the token is text-like

math_open,math_close

these wrap math-like portions of the token; the defaults try to give upright characters (non-italic) which may not work for Greek symbols

label_open,label_close

these re-wrap math-like portions of the token ifenforce_math is TRUE; defaults invoke traditional math mode

enforce_math

whether to enforce math mode for nested expression

...

ignored arguments

Value

latex

See Also

Other latex:[.latex(),[[.latex(),as_latex(),as_latex.default(),as_latex.greek(),as_latex.latex(),as_latex.spar(),as_latex.spork(),concatenate.latex()

Other interface:as.expression.plotmath(),as_html.spar(),as_html.spork(),as_latex.spar(),as_latex.spork(),as_plotmath.spar(),as_plotmath.spork(),as_previews.spork(),as_spork.character(),htmlToken(),plotmathToken()

Examples

latexToken('foo')latexToken('alpha')latexToken('Alpha')

Process Plotmath Token

Description

Processes a plotmath token. Escapes single-quotes and wraps in single-quotes.Also maps 'varepsilon' to 'epsilon', since plotmath has only the latter;likewise 'varrho' maps to 'rho' and 'varpi' maps to 'omega1'.

Usage

plotmathToken(  x,  conditional = getOption("plotmath_conditional_quote", FALSE),  unescape = getOption("plotmath_unescape", TRUE),  ...)

Arguments

x

(length-one) character

conditional

if true, return good tokens (parseable) unmodified; seegoodToken

unescape

whether to escape (unrecognized) backslash

...

ignored arguments

Value

plotmath

See Also

Other plotmath:[.plotmath(),[[.plotmath(),as.expression.plotmath(),as.png.plotmath(),as_plotmath(),as_plotmath.greek(),as_plotmath.spar(),as_plotmath.spork(),concatenate.plotmath(),ggplot.plotmath(),goodToken()

Other interface:as.expression.plotmath(),as_html.spar(),as_html.spork(),as_latex.spar(),as_latex.spork(),as_plotmath.spar(),as_plotmath.spork(),as_previews.spork(),as_spork.character(),htmlToken(),latexToken()

Examples

plotmathToken("can't")plotmathToken("\\", unescape = TRUE)plotmathToken("\\", unescape = FALSE)plotmathToken("\n", conditional = TRUE)plotmathToken("\n", conditional = FALSE)plotmathToken('alpha')plotmathToken('Alpha')

Objects exported from other packages

Description

These objects are imported from other packages. Follow the linksbelow to see their documentation.

ggplot2

ggplot


[8]ページ先頭

©2009-2025 Movatter.jp