wrap: Wrap strings

Description Usage Arguments See Also Examples

View source: R/paste.R

Description

Wrap strings with flanking characters

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
wrap(x, left, right = left)

dbl_quote(..., sep = "")

sngl_quote(..., sep = "")

bracket(..., sep = "")

brace(..., sep = "")

parens(..., sep = "")

Arguments

x

character to wrap

left, right

character pair to wrap with

sep, ...

passed to base::paste before wrapping

See Also

unwrap p0 sentence

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
wrap("abc", "__")  #  __abc__
parens("abc")      #   (abc)
sngl_quote("abc")  #   'abc'
dbl_quote("abc")   #   "abc"
bracket("abc")     #   [abc]
brace("abc")       #   {abc}

label <- p("name", parens("attribute"))

label             # "name (attribute)"
unparens(label)   # "name attribute"

# make your own function like this:
# markdown bold
bold <- function(...) wrap(paste(...), "**")
p("make a word", bold("bold"))
# see unbold example in ?unwrap

yasp documentation built on May 1, 2019, 6:36 p.m.

Related to wrap in yasp...