Learn R Programming

RSurvey (version 0.6-0)

EvalFunction: Evaluates an RStatement

Description

Evaluates a character string representation of an Rstatement.

Usage

EvalFunction(txt, cols)

Arguments

txt
character; a string representation of an Rfunction; see Details.
cols
list; see ManageData.

Value

  • The result of evaluating the txt object after the appropriate substitutions for DATA has been made. Inf, -Inf, and NaN values are converted to NA in numeric vectors.

Details

The DATA identifier is a reserved word within the txt argument. DATA is used to reference the data.raw data frame, a component of Data with variable names keyed to column index numbers in data.raw using the vars argument.

See Also

parse, eval, round, is.infinite, is.nan

Examples

Run this code
data(tritest)
Data("data.raw", as.data.frame(tritest))
cols <- list()
cols[[1]] <- list(id = "X", index = 1, fun = "DATA[["X"]]")
cols[[2]] <- list(id = "Y", index = 2, fun = "DATA[["Y"]]")
EvalFunction("DATA[["X"]]", cols)
cols[[1]]$digits <- 0
EvalFunction("DATA[["X"]]", cols)
EvalFunction("DATA[["X"]] + DATA[["Y"]]", cols)
EvalFunction("rnorm(12)", cols)

Run the code above in your browser using DataLab