Reputation: 1484
I would like to prefer a function (select) from the dplyr package. I loaded a package that depends on MASS package that masks select function. Is there an alternative way to prefer select from the dplyr package other than the convention dplyr::select()
?
Upvotes: 3
Views: 885
Reputation: 1534
If you don't want to worry aboutpackage loading order, as you see in @benson23 answer, this is one way:
library(dplyr)
library(MASS)
select <- dplyr::select
Another way is using conflicted package:
library(conflicted)
library(dplyr)
library(MASS)
conflict_prefer("select", "dplyr")
At last, if you use want to use tidymodels meta-package (includes dplyr), you can do this too:
library(tidyverse)
library(tidymodels)
library(MASS)
tidymodels_prefer()
Upvotes: 2
Reputation: 19097
I believe there are a few options for this:
Load your other packages first, and at last, load tidyverse
or dplyr
At the very beginning of your script, do
select <- dplyr::select
You can combine the above two options in your .Rprofile
file, so that every time you launch R, the above actions will be executed.
Upvotes: 1