When I loaded package debug
to debug a script with zoo
objects, I got trouble: function index
from zoo
got masked by debug
package. How can I unmask index
? In general, how to deal with these name colliding problems? We just do not use debug
package with `zoo'?
Order of Loading Packages in RIf two packages use the same function name, then the package loaded last will hide the function from earlier packages. This is called masking.
Because R is developed by an open source community, it is not uncommon that multiple packages may use the same name for a function or dataset. If you load packages that use the same name for an object, R will warn that certain object(s) have been “masked”.
You can unload the package which has masked functions and then reload it. It will regain precedence in the searchpath:
unloadNamespace("zoo")
library("zoo")
In the future, if you want to load a package while preventing it from masking other functions, you can specify its position in the search path with an arbitrary large number:
library("debug", pos = .Machine$integer.max)
Exported symbols are always identifiable with the ::
operator:
zoo::index
Hidden functions not declared in the namespace can still be accessed using :::
(triple-colon), and example would be
zoo:::.onLoad
which you can see even though it is not exported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With