From tplate at acm.org  Wed Apr 11 19:29:42 2007
From: tplate at acm.org (Tony Plate)
Date: Wed, 11 Apr 2007 11:29:42 -0600
Subject: [Rd] accessing hidden functions in testing code
Message-ID: <461D1B06.9020308@acm.org>

I'd like to be able to access unexported functions in the testing code 
for a package with a namespace.  I know that one way to do this is to 
use the ":::" operator, but I'd prefer to avoid cluttering up my testing 
code with lots of repetitions of "myPackageName:::".

One way I found to do this was to attach() the namespace of the package, 
e.g., using the following:

pkg <- "myPackageName"
library(package=pkg, character.only=TRUE)
## --- Load the name space to allow testing of private functions ---
if (is.element(pkg, loadedNamespaces()))
     attach(loadNamespace(pkg), name=paste("namespace", pkg, sep=":"), 
pos=3)


Are there any pitfalls that I will find if I continue with this 
approach?  Or is there another better way?

-- Tony Plate



[Rd] accessing hidden functions in testing code
Tony Plate