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. (2020). "calculus: High dimensional numerical and symbolic calculus in R". https://arxiv.org/abs/2101.00086

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)"