Skip to content
Prev 260410 / 398502 Next

identical function names from 2 packages

Duncan Murdoch <murdoch.duncan <at> gmail.com> writes:
I fail to see how namespace could help here. If you have identical function
names in two packages, one will still mask another and you'll need an explicit
pointer (::) to tell R which one to use. Here is an example:
Error in lm(y ~ x) : got you!
function (x, ...) 
stop("got you!")
<environment: namespace:teaser>

So there is an unreleased (fortunately!) package called "teaser" 
which has only function called lm() that seems to do nothing useful, but
it masks the more useful function lm() in package "stats".  Both packages
("teaser" and "stats") have namespace, but it didn't help here.

Namespace may be useful when you got stray objects from two different
packages, and these should be handled by their dedicated support functions,
but I fail to see how namespace could help in resolving which of the two exported
functions to use at the top level.

I have honest intentions in this query since I know that the package that I
maintain has a function with the same name as another package that is often
used alternately with our package. My resolution was to write a function that 
detects the case and gives user a warning that the object they have was
created from that another package and cannot be adequately handled here.
However, it doesn't remove the confusion when people think they are using
one package but use another when doing the top level analysis.

If there is a resolution to this, I'll be happy.

Cheers, Jari Oksanen