powered by
Variables are detected as a character followed by a number of either: character, number or underscore.
as_sym(x, declare_symbols = TRUE)
R object to convert to a symbol
declare detected symbols automatically
Default is to declare used variables. Alternatively, the user must declare them first, e.g. by symbol().
symbol()
Note that matrices can be defined by specifying a Python matrix, see below in examples.
if (has_sympy()) { x <- symbol("x") A <- matrix(c("x", 0, 0, "2*x"), 2, 2) A B <- as_sym(A) B 2*B dim(B) sqrt(B) D <- as_sym("[[1, 4, 5], [-5, 8, 9]]") D }
Run the code above in your browser using DataLab