Opening and closing parens will be added if an opening paren is not the first non-whitespace character.

ensure_parens(x)

Arguments

x

a list or vector

Value

x is returned, possibly modified with parens added.

Examples

ensure_parens(letters[1:4])
#> [1] "(a)" "(b)" "(c)" "(d)"
ensure_parens(as.list(letters[1:4]))
#> [[1]] #> [1] "(a)" #> #> [[2]] #> [1] "(b)" #> #> [[3]] #> [1] "(c)" #> #> [[4]] #> [1] "(d)" #>
ensure_parens(c("(a)", "b", "(c)"))
#> [1] "(a)" "(b)" "(c)"