[Rd] Visibility of methods in different namespaces

Thomas Etheber etheber at gmx.de
Thu Jul 22 13:56:26 CEST 2010


Hey folks,

I read plenty of material and started to write some new R-packages, but 
actually I am looking for a solution of the following problem. Perhaps 
it's a beginners question for creating packages, but I wasn't able to 
track it down yet. Hopefully you can provide me with a solution or at 
least some adequate readings.

I have a package say it's called "AAA" with an S4-object say it's called 
"aObject". On the other hand I have a package "BBB" with an S4-object 
called "bObject".
Both objects want to provide the same method to outside users, the 
method is called "calculateModel" and they were implemented in the 
package using the following S3 notation:

Package AAA:
---------------
calculateModel <- function( object, ...) { UseMethod( "calculateModel") }
calculateModel.aObject <- function( object, ..., 
someAdditionalParameters ) { bla bla }

Package BBB:
---------------
calculateModel <- function( object, ...) { UseMethod( "calculateModel") }
calculateModel.bObject <- function( object, ..., 
someAdditionalParameters ) { bla bla }


In the NAMESPACE file of package AAA and package BBB, I registered the 
methods using:

Package AAA:
---------------
S3method( "calculateModel", "aObject" )
export( "calculateModel"  )

Package BBB:
---------------
S3method( "calculateModel", "bObject" )
export( "calculateModel"  )

Everything works fine, when I load only one of the packages. But if I 
load both packages together, one of the calculateModel methods 
disappears and is no longer visible, which results in an error.

What am I missing?

Thanks!
Thomas



More information about the R-devel mailing list