The goal of conflicted is to provide an alternative conflict resolution strategy. R’s default conflict resolution system gives precedence to the most recently loaded package. This can make it hard to detect conflicts, particularly when introduced by an update to an existing package. conflicted takes a different approach, making every conflict an error and forcing you to choose which function to use.
To use conflicted, all you need to do is load it:
library(conflicted) library(dplyr) filter(mtcars, cyl == 8) #> [conflicted] `filter` found in 2 packages. #> Either pick the one you want with `::` #> * dplyr::filter #> * stats::filter #> Or declare a preference with `conflict_prefer()` #> * conflict_prefer("filter", "dplyr") #> * conflict_prefer("filter", "stats")
As suggested, you can either namespace individual calls:
Or declare a session-wide preference:
I recommend declaring preferences directly underneath the corresponding library call:
You can ask conflicted to report any conflicts in the current session:
Functions surrounded by
 have been chosen using one of the built-in rules. Here
filter() has been selected because of the preference declared above; the set operations have been selected because they follow the superset principle and extend the API of the base equivalents.
Loading conflicted creates a new “conflicted” environment that is attached just after the global environment. This environment contains an active binding for any object that is exported by multiple packages; the active binding will throw an error message describing how to disambiguate the name. The conflicted environment also contains bindings for
require() that suppress conflict reporting and update the conflicted environment with any new conflicts.
These require more upfront work than conflicted, in return for greater precision and control.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.