inside: Evaluate an Expression in a Data Environment

insideR Documentation

Evaluate an Expression in a Data Environment

Description

Evaluate an R expression in an environment constructed from data.

Usage

inside(data, expr, ...)

## S3 method for class 'list'
inside(data, expr, keepAttrs = TRUE, ...)

Arguments

data

Data to use for constructing an environment a data frame or a list.

expr

Expression to evaluate, often a “compound” expression, i.e., of the form

            {
                a <- somefun()
                b <- otherfun()
                .....
                rm(unused1, temp)
            }
        
keepAttrs

For the list method of inside(), a logical specifying if the resulting list should keep the attributes from data and have its names in the same order. Often this is unneeded as the result is a named list anyway, and then keepAttrs = FALSE is more efficient.

...

Arguments to be passed to (future) methods.

Details

This is a modified version of the base R function within)), with exactly the same arguments and functionality but only one fundamental difference: instead of returning a modified copy of the input data, this function alters the data directly.

Author(s)

Adrian Dusa

Examples

mt <- mtcars
inside(mt, hwratio <- hp/wt)

dim(mtcars)

dim(mt)

admisc documentation built on July 9, 2023, 5:54 p.m.

Related to inside in admisc...