[Rd] conditionally import a namespace?

From: Felix Andrews <felix_at_nfrac.org>
Date: Thu, 30 Oct 2008 17:40:17 +1100

Dear R-devel,

I have a problem defining the dependencies for a package.

My package (latticist, not yet released) "Suggests" RGtk2, but specifically does not require it. If RGtk2 is available, the user can call a function that builds a GUI with RGtk2. However, I do not want to attach the RGtk2 namespace, because it is irrelevant to the user and exports about 7500 symbols.

Last time I asked a similar question to this, Professor Ripley noted that the usual method to get around this situation is the use an explicit package prefix to function calls (the `::` operator). But this is not so easy with non-standard functions. Take this chunk of code:

widg <- gtkComboBoxEntryNewText()
widg["width-request"] <- 100

The first call is easy to prefix, as RGtk2::gtkComboBoxEntryNewText() but the others, `$.RGtkObject` and `[<-.RGtkObject` are not.

While I *could* rewrite all the code to use explicit functions, I think, the resulting code would be much less clear.

Essentially what I want to do is conditionally import the RGtk2 namespace.

Any suggestions?


Felix Andrews / 安福立
3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8

R-devel_at_r-project.org mailing list
Received on Thu 30 Oct 2008 - 06:42:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 30 Oct 2008 - 14:30:37 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive