[R] How to call a function defined within another function
Gabor Grothendieck
ggrothendieck at gmail.com
Thu Oct 20 15:20:43 CEST 2011
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
More information about the R-help
mailing list