set_: Assign values to variables

View source: R/caller.R

set_R Documentation

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)

Arguments

dest

A quotation specifying the destination environment and name.

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_).

Value

set_ returns val, invisibly.

Examples

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`

nseval documentation built on Dec. 8, 2022, 9:13 a.m.