Learn R Programming

caracas (version 1.0.1)

as_symbol: Convert object to symbol

Description

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

Usage

as_symbol(x, declare_variables = TRUE)

Arguments

x

R object to convert to a symbol

declare_variables

declare detected variables 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

Run this code
# NOT RUN {
if (have_sympy()) {
  x <- symbol("x")
  A <- matrix(c("x", 0, 0, "2*x"), 2, 2)
  A
  B <- as_symbol(A)
  B
  2*B
  dim(B)
  sqrt(B)
  D <- as_symbol("[[1, 4, 5], [-5, 8, 9]]")
  D
}

# }

Run the code above in your browser using DataLab