View source: R/plainNames2data.frameNames.R
plainNames2data.frameNames | R Documentation |
The variable names of a function are transformed from plain variable names to data.frame names
of the form x$<globalName>
.
plainNames2data.frameNames(modelFunction, plainNames)
modelFunction |
a function whose body contains variables with plain names. The function must not contain any arguments. |
plainNames |
a |
The input function must be of the form:
modelFunction<-function(){ ... <expression with variable1> ... }
The transformed function which is of the form:
function(x){ ... <expression with x$variable1> ... }
If there are local functions within the function modelFunction
defined, whose arguments
have identical names to any of the plainNames
the function fails!
mcSimulation
, estimate
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.