missing is used within a function to check whether a call to the function is missing a particular argument (returning TRUE) or whether a value was specified for the argument (FALSE).
  • x – An argument name of the parent function.

Example. The function below outputs the result of missing. Notice that even when the default is manually specified, missing still returns FALSE.
> test <- function(x=20){
+   return(missing(x))
+ }
> test()
[1] TRUE
> test(5)
> test(20)
Tip. The missing function is useful for initializing default behavior in a function.

Leave a Reply