Learn R Programming

genvar (version 0.0.2.0)

forvar: apply a function to each of a list of variables

Description

apply a function to each of a list of variables

Usage

forvar(varlist, action, macro = "%var")

Arguments

varlist

a list of variables in the format "var1 var2 var3" (or, if a single variable, it may be unquoted).

action

a quoted expression (must be quoted) to apply to each variable where the variable is represented in the expression by macro.

macro

an expression that will be replaced in action for each variable, by default %var.

Value

returns NULL, invisibly

Examples

Run this code
# NOT RUN {
use(cars, clear=TRUE)
forvar("speed dist", "gen(%var2, %var^2)")
listif()
# }

Run the code above in your browser using DataLab