paste_text: Paste Strings that may Include 'plotmath' or Markdown

Description Usage Arguments Details Value Note See Also

View source: R/text_util.bare.R

Description

Paste together text strings, where one or more of the strings may contain plotmath expressions or markdown/HTML tags. This is an internal function, not intended to be called by package users.

Usage

1
paste_text(x, ..., sep=c("plain"=" ", "plotmath"="~", "markdown"=" "))

Arguments

x, ...

One or more character vectors or data frames. Data frames should contain columns text, and optionally textspec and fontface. (A character vector is treated as a data frame with text as its only column.) textspec should indicate the content type of text; if not present it is inferred by looking for special prefixes in text. fontface should be 1 for plain text, 2 for bold, 3 for italic, and 4 for bold italic; if not present a value of 1 is assumed. Each data frame will have its rows recycled to match the number of rows in the longest.

sep

Character vector containing strings to be inserted between text from different arguments when pasting them together. It may have one string per valid textspec value, named by that value. Note that in plotmath, "*" juxtaposes two expressions with no space between them; "~" inserts some space; and "~~" inserts more.

Details

"plotmath" and "markdown" strings cannot be pasted together. When a "plain" string is pasted together with one of the other types, the result will have the textspec value of the non-plain text.

If a set of "plain" text strings to be pasted together use different fontfaces, the final text will use plotmath or markdown to accomodate the mixed faces.

Value

A data frame with columns text, textspec, and fontface. The number of rows equals the number in the longest data frame argument. text contains the row-by-row pasted-together text from the arguments, and textspec specifies the content type of each row. fontface is NA when textspec is "plotmath", 1 when textspec is "markdown", and taken from x when textspec is "plain".

Note

Changing "plain" text to "markdown" is incomplete. For example, literal * or _ will be misinterpreted as markdown codes.

See Also

plotmath


tablesgg documentation built on June 3, 2021, 1:06 a.m.