Make implicit products explicit

make_products_explicit(x, allowed_functions = getGroupMembers("Math"))

Arguments

x

user input

allowed_functions

functions (sequence of characters) that should not have products, e.g. cos, sin

Examples

make_products_explicit("2x")
#> [1] "2*x"
make_products_explicit("2(1+2)")
#> [1] "2*(1+2)"
make_products_explicit("x(y)")
#> [1] "x*(y)"
make_products_explicit("(1+2)3") # Not allowed by definition
#> [1] "(1+2)3"
make_products_explicit("(1+2)x") # Is allowed
#> [1] "(1+2)*x"
make_products_explicit("x(2+1) + sin(y)")
#> [1] "x*(2+1)+sin(y)"
make_products_explicit("sin(2+1) + x(y+1)")
#> [1] "sin(2+1)+x*(y+1)"
make_products_explicit("(2x)(y+1)")
#> [1] "(2*x)*(y+1)"