How to expose a function in R

When I downloaded the debug package to debug a script with zoo objects, I had a problem: the index function from zoo was masked by the debug package. How to expose index ? In general, how to deal with these problems faced by names? We just don't use the debug package with `zoo '?

+10
source share
3 answers

Exported characters are always identified using the :: operator:

 zoo::index 

Hidden functions not declared in the namespace can still be obtained using ::: (triple colon), and the example would be

 zoo:::.onLoad 

which you can see even if it is not exported.

+10
source

You can unload a package with masked features, and then reload it. It will return priority in the search path:

 unloadNamespace("zoo") library("zoo") 

In the future, if you want to download a package without allowing it to mask other functions, you can specify its position in the search path with an arbitrary large number:

 library("debug", pos = .Machine$integer.max) 
+10
source

It only disguises itself to you, but is not disguised as a zoo, so when the zoo function tries to use the index, it will still find its own index.

zoo also has a time.zoo method, so if z is a zoo object, you can use time (z) instead of index (z).

Finally, you can always go to zoo :: index to make sure you get it at the zoo.

+4
source

Source: https://habr.com/ru/post/899350/


All Articles