This function returns a standard error message for missing parameters.
Usage
dis_not_missing(.f, param = "x", call = rlang::caller_env(),
fact_check = "global")Arguments
- .f
Required logical scalar; the output of
missing(x))orrlang::is_missing(x), substituting the parameter name passed to either function as needed.- param
Required character scalar; the parameter name. The default uses the variable name
x, but this value can be set to a different static character scalar. Alternatively, you can userlang::caller_arg()to pull the parameter name passed by the functiondis_not_missing()is nested within. Regardless of the approach taken here, the resulting character scalar should match the object name passed to.f.- call
Required environment; the environment in which the function was called. If nesting
dis_not_missingwithin another function, it is recommended to provide the calling environment to ensure the correct environment is referenced usingrlang::caller_env()(default). If there are multiple levels of nesting, thecallargument can be used to pass an environment created in the outermost function.- fact_check
Required character scalar; whether to override fact checking environment setting. If
"global"(default),dis_characterwill follow the global setting. If"always",dis_characterwill ignore any global setting and will always checkx. This argument is primarily intended for Shiny developers who wish to usedisputeRin modules. See the vignette onvignette("developing", package = "disputeR")for details on how to use this function.
Value
This function will return either TRUE (if the input passes
all validation checks) or an error message.
Details
See the vignette on vignette("developing", package = "disputeR")
for details about internal validation of arguments for this function.
Examples
# create example function that uses dis_param()
example <- function(x){
dis_not_missing(.f = rlang::is_missing(x))
}
# example function
example(x = "test")
#> [1] TRUE
# create example function that uses dis_param() with different variable name
example <- function(var){
dis_not_missing(.f = rlang::is_missing(var), param = "var")
}
# example function
example(var = "test")
#> [1] TRUE