Skip to content

Unexpected interaction between missing() and a blank expression

2 messages · Hong Ooi, Peter Dalgaard

#
This is something I came across just now:

f <- function(x) missing(x)
z <- quote(expr=)

f(z)
# TRUE

The object z contains the equivalent of a missing function argument. Another method for generating a missing arg would be alist(a=)$a .

Should f(z) return TRUE in this case? I interpret missing() as checking whether the parent function call had a value supplied for the given argument. Here, I have supplied an argument (z), so I would expect f to return FALSE.
#
Missing values propagate in R, e.g.
[1] TRUE

This is technically done by having a "missing" object, which is not really intended to be visible to users, but pops up in a few esoteric constructions. Trying do anything constructive with the missing object usually leads to grief, or at least surprises, e.g.:
Error: argument "z" is missing, with no default

-pd