An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111019/bedfe348/attachment.pl>
How to call a function defined within another function
5 messages · Sébastien Bihorel, Uwe Ligges, Gabor Grothendieck
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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111020/82039c87/attachment.pl>
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.char
function (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
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111020/a8c7ece1/attachment.pl>