17

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.

RockScience
  • 17,932
  • 26
  • 89
  • 125

1 Answers1

32

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"))))
RockScience
  • 17,932
  • 26
  • 89
  • 125
  • well. it is showing functionA from package P interacts with something. But how I find the package Q that is interacting? – userJT Mar 13 '15 at 08:17
  • I think there is a base function to do that but cannot find it back. In the mean time I suggest simply the code above. – RockScience Mar 13 '15 at 08:32
  • 1
    ok the function I was looking for is `getAnywhere`. I edited the answer – RockScience Mar 13 '15 at 08:43
  • 1
    dang pesky lag command is everywhere. dplyr does it best! – thistleknot Nov 15 '20 at 15:58
  • 1
    @thistleknot, thanks for this comment; I was just about to decide NOT to use lag in a dplyr chain (and use Lag from Hmisc package which then masks "summarise" from dplyr). Your comment prompted me to try dplyr::lag which fixed my problem. – W Barker Nov 03 '22 at 11:35