massign: assign values to multiple variables

View source: R/massign.R

massignR Documentation

assign values to multiple variables

Description

assign values to multiple variables

Usage

massign(..., values = NULL, envir = parent.frame())

n %ma% v

Arguments

...

One or more names that can be used as variable names.

values

Values that are replicated where needed to assign to the variable names

envir

The environment in which the values are assigned (bound) to the variable names

n

Character vector with variable names.

v

Values that are replicated where needed to assign to the variable names

Acknowledgement

I encountered this function in a contribution by Tommy (https://stackoverflow.com/users/662787/tommy) in https://stackoverflow.com/questions/7519790/assign-multiple-new-variables-on-lhs-in-a-single-line. I adapted the function slightly to allow a character vector for the first argument and derived the binary operator %ma% from it. I also changed the name of the function from vassign to massign because the relevant feature is assignment to multiple variables.

Examples

## Not run: 
massign(aa,bb, values= c(16,30) )
c('aa','bb') %ma% c(16,30)

## End(Not run)

HanOostdijk/HOQCutil documentation built on July 28, 2023, 5:56 p.m.