as_sym {caracas}R Documentation

Convert object to symbol

Description

Variables are detected as a character followed by a number of either: character, number or underscore.

Usage

as_sym(x, declare_symbols = TRUE)

Arguments

x

R object to convert to a symbol

declare_symbols

declare detected symbols automatically

Details

Default is to declare used variables. Alternatively, the user must declare them first, e.g. by symbol().

Note that matrices can be defined by specifying a Python matrix, see below in examples.

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
}


[Package caracas version 1.1.0 Index]