Learn R Programming

dMod (version 0.3.2)

funC0: Evaluation of algebraic expressions defined by characters

Description

Evaluation of algebraic expressions defined by characters

Usage

funC0(x, variables = getSymbols(x, exclude = parameters), parameters = NULL,
  compile = FALSE, modelname = NULL, verbose = FALSE, convenient = TRUE,
  warnings = TRUE)

Arguments

x

Object of class eqnvec or a named character vector with the algebraic expressions

variables

character vector, the symbols that should be treated as variables

parameters

character vector, the symbols that should be treated as parameters

compile

Logical. The function is either translated into a C file to be compiled or is evaluated in raw R.

modelname

file name of the generated C file.

verbose

Print compiler output to R command line.

convenient

logical, if TRUE return a function with argument ... to pass all variables/parameters as named arguments

warnings

logical. Suppress warnings about missing variables/parameters that are automatically replaced by zero values.

Value

Either a prediction function f(..., attach.input = FALSE) where the variables/parameters are passed as named arguments or a prediction function f(M, p, attach.input = FALSE) where M is the matrix of variable values (colums with colnames correspond to different variables) and p is the vector of parameter values. The argument attach.input determines whether M is attached to the output. The function f returns a matrix.

Examples

Run this code
# NOT RUN {
myfun <- funC0(c(y = "a*x^4 + b*x^2 + c"))
out <- myfun(a = -1, b = 2, c = 3, x = seq(-2, 2, .1), attach.input = TRUE)
qplot(x = x, y = y, data = as.data.frame(out), geom = "line")
# }

Run the code above in your browser using DataLab