Learn R Programming

nseval (version 0.5.1)

set_: Assign values to variables.

Description

set_ is a normally-evaluating version of <-. set_enclos_ is a normally evaluating version of <<-.

Usage

set_(dest, val)

set_enclos_(dest, val)

Value

set_ returns val, invisibly.

Arguments

dest

A quotation specifying the destination environment and name. This can also be an indexing, expression, and set_ will perform subassignment.

val

The value to assign.

Details

set_ differs from [assign] in that set_ will process subassignments.

These helpers are here because it is tricky to use do_ with <- (see Note under do_).

Examples

Run this code
set_(quo(x), 12) #equivalent to `x <- 12`
set_(quo(x[3]), 12) #equivalent to `x[3] <- 12`
e <- new.env()
set_(quo(x[3], e), 12) #assigns in environment `e`
set_enclos_(quo(x[3], e), 12) #assigns in a parent of environment `e`

Run the code above in your browser using DataLab