conflict_prefer() allows you to declare "winners" of conflicts. You can either declare a specific pairing (i.e. dplyr::filter() beats base::filter()), or an overall winner (i.e. dplyr::filter() beats all comers).

Use conficted_prefer_all() to prefer all functions in a package, or conflicted_prefer_matching() to prefer functions that match a regular expression.

conflict_prefer(name, winner, losers = NULL, quiet = FALSE)

conflict_prefer_matching(pattern, winner, losers = NULL, quiet = FALSE)

conflict_prefer_all(winner, losers = NULL, quiet = FALSE)

Arguments

name

Name of function.

winner

Name of package that should win the conflict.

losers

Optional vector of packages that should lose the conflict. If omitted, winner will beat all comers.

quiet

If TRUE, all output will be suppressed

pattern

Regular expression used to select objects from the winner package.

Best practices

I recommend placing calls to conflict_prefer() at the top of your script, immediately underneath the relevant library() call.

Examples

# Prefer over all other packages
conflict_prefer("filter", "dplyr")
#> [conflicted] Will prefer dplyr::filter over any other package

# Prefer over specified package or packages
conflict_prefer("filter", "dplyr", "base")
#> [conflicted] Removing existing preference
#> [conflicted] Will prefer dplyr::filter over base::filter
conflict_prefer("filter", "dplyr", c("base", "filtration"))
#> [conflicted] Removing existing preference
#> [conflicted] Will prefer dplyr::filter over base::filter, filtration::filter

# Prefer many functions that match a pattern
if (FALSE) {
# Prefer col_* from vroom
conflict_prefer_matching("^col_", "vroom")
}
# Or all functions from a package:
if (FALSE) {
# Prefer all tidylog functions over dtplyr functions
conflict_prefer_all("tidylog", "dtplyr")
}