massign | R Documentation |
assign values to multiple variables
massign(..., values = NULL, envir = parent.frame())
n %ma% v
... |
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 |
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.
## Not run:
massign(aa,bb, values= c(16,30) )
c('aa','bb') %ma% c(16,30)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.