Wraps characters in round brackets.

wrap(x)

Arguments

x

character.

Value

character.

Details

Characters are automatically wrapped when performing basic symbolic operations to prevent unwanted results. E.g.: $$a+b * c+d$$ instead of $$(a+b) * (c+d)$$ To disable this behaviour run options(calculus.auto.wrap = FALSE).

References

Guidotti E (2022). "calculus: High-Dimensional Numerical and Symbolic Calculus in R." Journal of Statistical Software, 104(5), 1-37. doi:10.18637/jss.v104.i05

See also

Other utilities: c2e(), e2c(), evaluate()

Examples

### wrap characters
wrap("a+b")
#> [1] "(a+b)"

### wrap array of characters
wrap(array(letters[1:9], dim = c(3,3)))
#>      [,1]  [,2]  [,3] 
#> [1,] "(a)" "(d)" "(g)"
#> [2,] "(b)" "(e)" "(h)"
#> [3,] "(c)" "(f)" "(i)"