[R] R object as a function
Thomas Steiner
finbref.2006 at gmail.com
Tue Jan 22 11:30:03 CET 2008
I want to use a function as an argument to ingtegrate it twice.
See the following (senseless) example of a double integration:
test<-function(sf,lo,up,rest) {
innerFkn<-function(sf,lo) {
inte=integrate(f=sf,lower=lo,upper=4)
return( inte$value )
}
integral=integrate(f=innerFkn,lower=1,upper=2,sf=sf,lo=lo,up=up)
return( integral$vlaue+rest )
}
test(sf=stepfun(c(0,1),c(2,-1,3)),lo=0,up=2,rest=12)
Why isn't it possible to define the "innerFkn" inside "test"?
"sf" is a stepfun, but it should possibly be any function.
How can I define some R object like a stepfun (depending on variables)
which can be evaluated like a function at some "lo"?
Thanks for help,
Thomas
More information about the R-help
mailing list