A situation that often comes up on SO, is packages having overwritten functions causing unexpected errors in packages that rely on certain function definitions (for example MASS::negative.binomial
and GLMMadaptive::negative.binomial
has different argument, which causes some dependent packages to fail).
If the function clashing is exported from the package, a fix that doesn't require closing and opening R
can often be achieved as
pck <- find("negative.binomial")
if(length(pck) > 0){
suppressWarnings(sapply(unlist(pck), function(x)
detach(x, unload = TRUE,
force = TRUE, character.only = TRUE))
}
if(length(find("negative.binomial")) == 0)
cat("Succes!\n")
(credits to the popular question here, for the idea.)
But in the case that a function or a method of a function is not exported, eg. lme4:::influence.merMod
and car:::influence.merMod
, find
won't find the function
>library(lme4)
>library(car)
>find("influence.merMod")
character(0)
Given only the method of function as a string, how would one find
the attached
packages which includes a specific none-exported function or method?