funC0: Evaluation of algebraic expressions defined by characters

Description Usage Arguments Value Examples

View source: R/eqnClass.R

Description

Evaluation of algebraic expressions defined by characters

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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. Directly compile the file. If FALSE and modelname is available, the C file is written but not compiled. In this case, compile has to be called separately to compile one or more .c-files into one .so-file. If modelname is not available, an R function is generated and returned.

modelname

file name of the generated C file. See description of parameter compile.

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

1
2
3
4
library(ggplot2)
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")

dMod documentation built on Jan. 27, 2021, 1:07 a.m.