[R] Unwanted association between a function and a namespace

Duncan Murdoch
2009-12-23T21:25:58Z

On 23/12/2009 3:36 PM, p_connolly at slingshot.co.nz
wrote:
> I can't understand how the plyr package is turning up here:
>
>> sessionInfo()
> R version 2.10.1 (2009-12-14)
> i686-pc-linux-gnu
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] grDevices utils     stats     graphics  methods   base
>
> other attached packages:
> [1] lattice_0.17-26
>
> loaded via a namespace (and not attached):
> [1] grid_2.10.1 plyr_0.1.9
>
> I can understand that lattice would be using grid without having that
> package loaded, but I can't understand how plyr got there.

One way for this to happen is if you have a copy of a function from plyr
in your global environment.  The functions in plyr reference its
namespace, so you'd get it loaded that way.

>
> It wouldn't matter if that namespace hadn't become associated
somehow
> with a function I have somewhere else on the search path (thereby
> rendering the function unfindable).

This doesn't make sense.  If the function is on the search path, it
doesn't matter what namespace is associated with it:  you'll find it.
If you have a function with the same name in globalenv() then you'll
have problems.  The simple solution is to remove it (e.g. rm(f)); a
better long term solution is to *never* store anything in your workspace
between sessions.  Start with a clean global environment each time.

Duncan Murdoch

My guess is that if I knew how that
> happened, I'd then know why plyr is loaded by namespace.  However,
I'm
> lost for ideas on how that could have happened.
>
> Suggestions as to where I should be looking greatly appreciated.  Or, even
> if that's unknowable, how to remove the association between the
namespace
> and the function.
>
> TIA
>
> --
> Patrick Connolly
> Plant & Food Research
> Mt Albert
> Auckland
> New Zealand
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
> I have the world`s largest collection of seashells. I keep it on all
> the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.