Suppose I write a wrapper function of jsonlite::fromJSON
but use different default value for simplifyDataFrame=
:
read.json <- function(txt, ...) {
jsonlite::fromJSON(txt, simplifyDataFrame = FALSE, ...)
}
read.json
is thus a wrapper function of jsonlite::fromJSON
with different default parameter. However, if user specifies simplifyDataFrame = TRUE
to override the default of read.json
there would be an argument name clash.
> read.json('{"a":1}')
$a
[1] 1
> read.json('{"a":1}', simplifyDataFrame = TRUE)
Error in jsonlite::fromJSON(txt, simplifyDataFrame = FALSE, ...) :
formal argument "simplifyDataFrame" matched by multiple actual arguments
What is the best/correct way to write a wrapper function with different default values of parameters that does not lead to potential name clash?