Remove (or exclude) one function from imported package
The other alternative would be to use
recode <- SILLY_PROPRIETARY_PACKAGENAME::recode
at the head of your code (with an explanatory comment) to create a copy of recode
in the global workspace (which should then mask the version from dplyr
). This could prevent future confusion when you hand your code to someone who has the stock dplyr
, rather than your personally hacked version, installed.
R 3.3.0 or later now support "import all but x,y,z from foo" statements:
\item The \code{import()} namespace directive now accepts an argument \code{except} which names symbols to exclude from the imports. The \code{except} expression should evaluate to a character vector (after substituting symbols for strings). See Writing R Extensions.
Methinks that is exactly what you want here, and want most people want who do not intend to have dplyr clobber over functions from the stats package included with R such as filter
or lag
.
Edited based on later discussion in comments:
Example usage example in file NAMESPACE
per Section 1.5.1 of WRE is as follows:
import(dplyr, except = c(recode, lag, filter))
Use the Hack-R version of dplyr
instead of the Hadley version. Given that I created this in the past 2 minutes, you could also easily make your own version.
require(devtools)
install_github("hack-r/dplyr")
require(dplyr)
All I did was fork it, open the project in RStudio via version control, remove recode
, commit, and push it back to my GitHub.