There is a functionality in my package that should be used with caution.
The user should be aware of this but if he/she thinks that the situation is OK then it would be bothering to show the warning each time the function is called.
I often see warnings that are displayed only once. They are quite painful to debug so I couldn't find a reproducible example (I'll add one if I get any) but they show a specific warning message, followed by the rlang
info:
This warning is displayed once per session
There are a lot of help wanted to debug those messages (for instance here, here, or here, just google "r This warning is displayed once per session")
I think that the package lifecyle
often uses those for soft-deprecation, but I wasn't able to discover the trick in lifecycle:::lifecycle_build_message
.
How can I throw such a warning in my package?
EDIT:
Here is a reproducible example. You have to restart your R session for it to show again. As you can see, options(warn=2)
had no impact.
options(warn=2)
xx=c("Sepal.Width")
tidyselect::vars_select(names(iris), xx)