Is there a standard way of deprecating arguments in R?
Example: For a web API package, I previously included a paging=TRUE
argument which would paginate over all the results and download everything.
Now I want to have a limit
argument instead, and only download everything if set to limit=0
. This effectively eliminates the need for the paging
argument, so I need to let people now it basically does nothing now. How do I do that?
To deprecate a class or method, use the @deprecated tag, as explained in How to Write Doc Comments for JavaDoc. The paragraph following the @deprecated tag should explain why the item has been deprecated and suggest how the user can avoid using it.
Usage of a module may be 'deprecated', which means that it may be removed from a future Python release.
Something like as follows maybe would do for you?
foo <- function(paging = T, limit = 0) {
if (!missing("paging"))
warning("argument deprecated")
}
Example outputs:
# > foo()
# > foo(limit = 0)
# > foo(T)
# Warning message:
# In foo(T) : argument deprecated
# > foo(paging = T)
# Warning message:
# In foo(paging = T) : argument deprecated
As @Roland points out, it should also be mentioned in the documentation for that function that the argument is now deprecated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With