-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make all arguments (except method
and data
) optional
#24
Comments
@hanneoberman and @stefvanbuuren
Because of that we currently hard-coded their values if they are not given in the API call. And of course we risk that the HTTP API will not be synchronised automatically when those values get updated. Is it possible to |
Would something like this work? get_defaults <- function(m, maxit, seed) {
m <- ifelse(is.null(m), 5, m)
maxit <- ifelse(is.null(maxit), 5, maxit)
seed <- ifelse(is.null(seed), NA, seed)
list(m = m, maxit = maxit, seed = seed)
}
get_defaults(NULL, NULL, NULL)
#> $m
#> [1] 5
#>
#> $maxit
#> [1] 5
#>
#> $seed
#> [1] NA
get_defaults(m = NULL, maxit = NULL, seed = NULL)
#> $m
#> [1] 5
#>
#> $maxit
#> [1] 5
#>
#> $seed
#> [1] NA Created on 2023-11-24 with reprex v2.0.2 |
That looks great. We can also drop the parameters for the function if the return value is a named list with all parameters with a preset value. |
Perhaps the function |
No description provided.
The text was updated successfully, but these errors were encountered: