jakub jakub - 2 days ago 3
R Question

How to deprecate an argument?

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?

Answer

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
Comments