Utility that returns a function to increment a variable in a data-frame.
A functional approach to defining an increment in one or more variables in a data-frame. Given a variable name and an increment value, return a function that takes any data-frame to return a data-frame with incremented values.
incrVar(var, increment = 1)
var |
String for the name(s) of the variable(s) to be incremented |
increment |
Value that the variable should be incremented. |
Useful for defining transformations for calculating rate ratios.
A function with a single data
argument that increments the variables
in the data
list/data-frame.
##---- Should be DIRECTLY executable !! ---- ##-- ==> Define data, use random, ##-- or do help(data=index) for the standard data sets. ## The function is currently defined as function (var, increment = 1) { n <- length(var) if (n > 1 && length(increment)==1) increment <- rep(increment, n) function(data) { for (i in 1:n) { data[[var[i]]] <- data[[var[i]]] + increment[i] } data } }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.