overwrite: Overwrite an object in a given environment.

overwriteR Documentation

Overwrite an object in a given environment.

Description

Utility function to overwrite an object, and bypass the assignment operator.

Usage

overwrite(objname, content, environment)

Arguments

objname

Character, the name of the object to overwrite.

content

An R object

environment

The environment where to perform the overwrite procedure.

Value

This function does not return anything.

Author(s)

Adrian Dusa

Examples

foo <- function(object, x) {
    objname <- deparse(substitute(object))
    object <- x
    overwrite(objname, object, parent.frame())
}


bar <- 1
foo(bar, 2)

bar
# [1] 2

bar <- list(A = bar)
foo(bar$A, 3)

bar

admisc documentation built on Sept. 12, 2024, 6:27 a.m.

Related to overwrite in admisc...