Sébastien Bihorel
2011-Oct-19 20:08 UTC
[R] How to call a function defined within another function
Dear R-users, I would need some advices on the proper way to call a particular function. This function is called scope.char and it is embedded in the step.gam function from the gam package. I am trying to call scope.char directly in a script but I did not find the proper way to do so. Is this even possible? If so, what is the proper syntax? Thank you for your time and help. Sebastien [[alternative HTML version deleted]]
Uwe Ligges
2011-Oct-20 09:40 UTC
[R] How to call a function defined within another function
On 19.10.2011 22:08, S?bastien Bihorel wrote:> Dear R-users, > > I would need some advices on the proper way to call a particular function. > This function is called scope.char and it is embedded in the step.gam > function from the gam package. I am trying to call scope.char directly in a > script but I did not find the proper way to do so. Is this even possible? If > so, what is the proper syntax? >You cannot, since it is only defined in the environment of the function step.gam while that is active. The gam license is "GPL-2", so go ahead. Best, Uwe Ligges> Thank you for your time and help. > > Sebastien > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Gabor Grothendieck
2011-Oct-20 13:20 UTC
[R] How to call a function defined within another function
On Wed, Oct 19, 2011 at 4:08 PM, S?bastien Bihorel <pomchip at free.fr> wrote:> Dear R-users, > > I would need some advices on the proper way to call a particular function. > This function is called scope.char and it is embedded in the step.gam > function from the gam package. I am trying to call scope.char directly in a > script but I did not find the proper way to do so. Is this even possible? If > so, what is the proper syntax? > > Thank you for your time and help. >As has already pointed out it can't really be done but if you want a hack then this will do it. It does depend on the specific position of scope.char within step.gam,> library(gam) > eval(body(step.gam)[[2]]) > > # check that its now there > scope.charfunction (formula) { formula = update(formula, ~-1 + .) tt <- terms(formula) tl <- attr(tt, "term.labels") if (attr(tt, "intercept")) c("1", tl) else tl } -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Maybe Matching Threads
- How to modify the dot-dot-dot argument using level names instead of position
- Question about output from optim
- How to automate the detection of break points for use in cut
- Listing of available functions
- Define ylim in lattice plot based upon panel function output