Missing arguments
- Empty symbols
- To create an empty symbol, you need to use
missing_arg()
or expr()
.
missing_arg()
#> Error in evalq(print(value), envir = print_env): argument "value" is missing, with no default
typeof(missing_arg())
#> [1] "symbol"
- Empty symbols don’t print anything.
- To check, we need to use
rlang::is_missing()
is_missing(missing_arg())
#> [1] TRUE
# [1] TRUE
- These are usually present in function formals:
f <- expr(function(x, y = 10) x + y)
# function(x, y = 10) x + y
args <- f[[2]]
# $x
#
#
# $y
# [1] 10
#
is_missing(args[[1]])
#> [1] TRUE
#> [1] TRUE