cg_surround: Surround a string

View source: R/code_gen.R

cg_surroundR Documentation

Surround a string

Description

Surround a string

Usage

cg_surround(
  x,
  surround = "()",
  style = c("single", "sandwich"),
  inner_indent = 0
)

Arguments

x

the string to surround

surround

enclosing characters. See details.

style

the style of surrounding. See details.

inner_indent

the indent of the inner part of the sandwich. Only used when ‘style = ’sandwich''.

Details

The argument to 'surround' should be 1 or 2 characters. If 1, then the returned string will be enclosed in that character. If 2, then the returned string will be enclosed by the first on the left and the second on the right. See examples for the style argument.

Value

a surrounded string

Examples

x <- month.abb[1:3]
cg_surround(x, '"')
cg_surround(x, style = 'sandwich')
cg_surround(x, '{}', 'sandwich', 2)

colin-fraser/colinlib documentation built on Nov. 30, 2022, 11:10 p.m.