Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

parenthesize

Wrap a string in brackets


Description

Parenthesise a character vector by wrapping elements in brackets, dashes or commas.

Usage

parenthesize(
  x,
  type = c("round_brackets", "square_brackets", "curly_brackets", "angle_brackets",
    "chevrons", "hyphens", "en_dashes", "em_dashes", "commas")
)

parenthesise(
  x,
  type = c("round_brackets", "square_brackets", "curly_brackets", "angle_brackets",
    "chevrons", "hyphens", "en_dashes", "em_dashes", "commas")
)

Arguments

x

Character vector to wrap in parenthenses.

type

String naming the type of parenthesis.

Value

A character vector of the input wrapped in parentheses.

Note

English grammar terminology is awfully confusing. The verb 'to parenthesise' means to wrap a phrase in brackets or dashes or commas, thus denoting it as supplementary material that could be left out. A 'parenthesis' as a noun is often used as a synonym for a round bracket.

See Also

Examples

paste("There were three", parenthesise(3), "mice in the experiment.")
paste(
  "I love parmos", 
  parenthesise("Teesside's finest culinary invention", "en_dashes"), 
  "but they are sure to give me heart disease."
)
parenthesise(letters[1:5], "curly")
paste0(
  "The R language", 
  parenthesise("an offshoot of S and Scheme", "commas"), 
  "is quite good for data analysis."
)

assertive.base

A Lightweight Core of the 'assertive' Package

v0.0-9
GPL (>= 3)
Authors
Richard Cotton [aut, cre], Sunkyu Choi [trl], Ivanka Skakun [trl], Gergely Dar<c3><b3>czi [trl], Anton Antonov [trl], Hisham Ben Hamidane [trl], Anja Billing [trl], Aditya Bhagwat [trl], Rasmus B<c3><a5><c3><a5>th [trl], Mine Cetinkaya-Rundel [trl], Aspasia Chatziefthymiou [trl]
Initial release
2021-02-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.