Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list of masked functions in R

I use a lot of packages and I know some functions are masked because they exist in several different packages. Is there a way to get the list of duplicate functions (or masked functions?)

The ideal would be to have a list of duplicate function and for each of them, the list of packages in which it exists.

like image 320
RockScience Avatar asked Jun 15 '11 07:06

RockScience


People also ask

What are masked objects in R?

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”.

What is masking and name conflicts in R programming?

Description. conflicts reports on objects that exist with the same name in two or more places on the search path, usually because an object in the user's workspace or a package is masking a system object of the same name. This helps discover unintentional masking.


1 Answers

in R base:

 conflicts(detail=TRUE)

And to find the list of environments that contain a version of

getAnywhere(x = "functionA")

Note: getAnywhere also finds the functions which are not exported. and that are hence not creating conflicts.

A better (simpler) result could be obtained using:

x = "functionA"
names(which(sapply(search(), FUN = function(env) exists(x, env, inherits = FALSE, mode = "function"))))
like image 50
RockScience Avatar answered Sep 21 '22 13:09

RockScience