plainNames2data.frameNames {decisionSupport}R Documentation

Transform model function variable names: plain to data.frame names.

Description

The variable names of a function are transformed from plain variable names to data.frame names of the form x$<globalName>.

Usage

plainNames2data.frameNames(modelFunction, plainNames)

Arguments

modelFunction

a function whose body contains variables with plain names. The function must not contain any arguments.

plainNames

a character vector containing the names of the variables that shall be transformed.

Details

The input function must be of the form:

   modelFunction<-function(){
     ...
     <expression with variable1>
     ...
   }
 

Value

The transformed function which is of the form:

   function(x){
     ...
     <expression with x$variable1>
     ...
   }
 

Warning

If there are local functions within the function modelFunction defined, whose arguments have identical names to any of the plainNames the function fails!

See Also

mcSimulation, estimate

Examples

 profit1<-function(){
   list(Profit=revenue-costs)
 }
 profit2<-plainNames2data.frameNames(modelFunction=profit1, 
                                               plainNames=c("revenue", "costs"))
 print(profit2)
 is.function(profit2)
 profit2(data.frame("revenue"=10,"costs"=2))

[Package decisionSupport version 1.114 Index]