deprecate_soft {lifecycle} | R Documentation |
These functions provide three levels of verbosity for deprecated functions.
deprecate_soft()
warns only if the deprecated function is
called from the global environment (so the user can change their
script) or from the package currently being tested (so the
package developer can fix the package). Use for soft-deprecated
functions.
deprecate_warn()
warns unconditionally. Use for deprecated functions.
deprecate_stop()
fails unconditionally. Use for defunct functions.
Warnings are only issued once every 8 hours to avoid overwhelming the user. See the verbosity option to control this behaviour.
Deprecation warnings have class
lifecycle_warning_deprecated
. Deprecation errors have class
lifecycle_error_deprecated
.
deprecate_soft( when, what, with = NULL, details = NULL, id = NULL, env = caller_env(2) ) deprecate_warn( when, what, with = NULL, details = NULL, id = NULL, env = caller_env(2) ) deprecate_stop(when, what, with = NULL, details = NULL)
when |
The package version when function/argument was deprecated. |
what |
If the deprecated feature is a whole function, the
function name: You can optionally supply the namespace: |
with |
An optional replacement for the deprecated feature.
This should be a string of the same form as |
details |
The deprecation message is generated from |
id |
The id of the deprecation. A warning is issued only once
for each |
env |
The environment in which the deprecated function was called. A warning is issued if called from the global environment. If testthat is running, a warning is also called if the deprecated function was called from the package being tested. This typically doesn't need to be specified, unless you call
|
NULL
, invisibly.
# A deprecated function `foo`: deprecate_warn("1.0.0", "foo()") # A deprecated argument `arg`: deprecate_warn("1.0.0", "foo(arg = )") # A partially deprecated argument `arg`: deprecate_warn("1.0.0", "foo(arg = 'must be a scalar integer')") # A deprecated function with a function replacement: deprecate_warn("1.0.0", "foo()", "bar()") # A deprecated function with a function replacement from a # different package: deprecate_warn("1.0.0", "foo()", "otherpackage::bar()") # A deprecated function with an argument replacement: deprecate_warn("1.0.0", "foo()", "foo(bar = )")