[R] Accessing functions in a library

Seth Falcon sfalcon at fhcrc.org
Wed Mar 8 21:37:35 CET 2006


"Michael Conklin" <michael.conklin at markettools.com> writes:

> I am trying to write a modified function to plot an rpart object.  By
> using getS3method I can see the plot and text code that I want to
> modify.  Since I don't want to modify the package, I create a new
> function to plot the rpart object.  The problem is that the original
> function calls many rpart specific functions that are only visible
> inside the rpart namespace.  Therefore, when I call my modified function
> it does not find the rpart specific functions and gives me an error.
> How can I make a new function that is a small modification of an
> existing package function and let the modified function access the
> hidden package functions?

You can subvert namespace protection using ":::".  So if there is a
hidden function g in package foo, use foo:::g().




More information about the R-help mailing list