I load a dozen of packages when I work, mostly tidyverse, which I trust enough to manage their conflicts with base R. Therefore, I would like to get rid of the expected conflict warnings when I load them.
As read in ?library and understood in https://stackoverflow.com/a/62384440/3888000 which is itself citing the official R-blog), I tried to use the mask.ok argument, either in library() or in options().
However, this does not seem to work as intended:
Sys.setenv(LANGUAGE="en")
options(conflicts.policy="depends.ok")
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
Created on 2022-07-01 by the reprex package (v2.0.1)
I also tried a lot of other options with no more success. Here is a testing code that unload and reload lubridate with different settings. It can run but the warnings remain.
f = function(mask.ok=NULL){
detach("package:lubridate", unload=TRUE)
if(is.null(mask.ok)) library(lubridate)
else library(lubridate, mask.ok=x)
}
f("base")
f(list(base=TRUE))
options(conflicts.policy=list(can.mask="base"))
f()
options(conflicts.policy=list(can.mask=list(base=TRUE)))
f()
conflictRules("lubridate", mask.ok="base")
f()
options(conflicts.policy = list(error = TRUE,
generics.ok = TRUE,
can.mask = c("base", "methods", "utils",
"grDevices", "graphics",
"stats"),
depends.ok = TRUE))
f()
Only this works, but I guess it will muffle the unexpected warnings as well:
detach("package:lubridate", unload=TRUE)
options(conflicts.policy=list(warn=FALSE))
library(lubridate)
Am I doing this wrong?