[Rd] [External] Feature Request: User Prompt + Message First Execution when "Managing Search Path Conflicts"
Juan Telleria Ruiz de Aguirre
jte||er|@@rproject @end|ng |rom gm@||@com
Thu May 21 13:09:15 CEST 2020
Thank you Mr. Tierney!
Using globalCallingHandlers() to directly handle
"packageConflictError" is an excellent idea!
The benefits I see for such an implementation are:
* The patch would be contained within the Conflict Error Handler,
which should reduce any side effects with an eventual implementation.
* And by making its usage optional, by setting for example
options(conflicts.policy.ask = TRUE), in should neither affect any
packages nor other base code.
Hope it allows R Users to work in a more agile manner, and guide R
Students through best practices of variable conflict handling in an
educative manner.
Thanks,
Juan
> You can get what you are asking for now in R 4.0.0 with
> globalCallingHandlers and using the packageConflictError object that
> is signaled. This should get you started:
>
> ```
> options(conflicts.policy = "strict")
>
> packageConflictError
>
> handle_conflicts <- function(e) {
> cat(conditionMessage(e))
> opt <- readline(prompt="1: mask.ok; 2: exclude. Choose: ")
> if (opt == "1")
> conflictRules(e$package, mask.ok = as.character(unlist(e$conflicts)))
> else if (opt == "2")
> conflictRules(e$package, exclude = as.character(unlist(e$conflicts)))
> stop("unresolved conflicts") ## ideal invode a restart here
> }
>
> globalCallingHandlers(packageConflictError = handle_conflicts)
>
> library(dplyr)
> ```
>
> An IDE could provide a more sophisticated interface, like a dialog
> allowing separate choices for each conflict. But this is best left up
> to the IDE or the user.
>
> The one addition to library that might be worth considering is to
> provide a restart for the handler to invoke.
>
> Best,
>
> luke
>
More information about the R-devel
mailing list