Learn R Programming

caracas (version 2.1.1)

def_sym: Define (invisibly) caracas symbols in global environment

Description

Define (invisibly) caracas symbols in global environment

Define symbol for components in vector

Usage

def_sym(..., charvec = NULL, warn = FALSE, env = parent.frame())

def_sym_vec(x, env = parent.frame())

Value

Names of declared variables (invisibly)

Arguments

...

Names for new symbols, also supports non-standard evaluation

charvec

Take each element in this character vector and define as caracas symbols

warn

Warn if existing variable names are overwritten

env

The environment in which the assignment is made.

x

Character vector.

See Also

symbol(), as_sym()

Examples

Run this code
if (has_sympy()) {
  ls()
  def_sym(n1, n2, n3)
  ls()
  def_sym("x1", "x2", "x3")
  ls()
  # def_sym("x1", "x2", "x3", warn = TRUE) # Do not run as will cause a warning
  ls()
  def_sym(i, j, charvec = c("x", "y"))
  ls()
}

if (has_sympy()) {
  def_sym(z1, z2, z3)
  u <- paste0("u", seq_len(3))
  ## Creates symbols u1, u2, u3 and binds to names u1, u2, u3 in R.
  def_sym_vec(u) 
  ## Same as (but easier than)
  def_sym(u1, u2, u3)
  ## Notice: this creates matrix [u1, u2, u3]
  as_sym(u)
 }

Run the code above in your browser using DataLab