as_sym: Convert R object to caracas symbol

View source: R/sym_as_sym.R

as_symR Documentation

Convert R object to caracas 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
}


caracas documentation built on Oct. 17, 2023, 5:08 p.m.