[Rd] How to build a list with missing values? What is missing, anyway?

peter dalgaard pdalgd at gmail.com
Fri Oct 5 08:34:13 CEST 2012

On Oct 5, 2012, at 03:31 , Peter Meilstrup wrote:

> On Thu, Oct 4, 2012 at 6:12 PM, Bert Gunter <gunter.berton at gene.com> wrote:
>> The R Language definition manual explains all of this. Read it.
> I always reread that before I post to this list.
> The only relevant mention of "missing" in the R Language Definition
> that I could find were in section 4.1.2 on page 25, and that section
> did not answer anything about "missing" as a special symbol (e.g. that
> my be put in a formal argument list.)

It's not defined as an R object. We did consider doing so briefly, but the semantics would be weird, as you have experienced: An R object that can't be evaluated without triggering an error. 

It is something that is used by the internals, so that missing values propagate with lazy evaluation semantics. It happens to be implemented as the equivalent of as.name(""), but that's not to be relied upon. It leaks out into user space because arguments can have missing defaults, and there needs to be a way to manipulate argument lists. It also slips out in substitute() with no argument, and I suppose that too is at least semi-intentional. It is not completely obvious that the two are necessarily identical.

It's one of those things where you shouldn't rely on behavior outside of well-establihed idioms. If you do, and it breaks, you get to keep both pieces...

I suppose we could try documenting it better, but it would be at the risk of authorizing semantics that we might want to change (e.g., it is far from clear that we should be allowing direct assignment of missings to simple symbols).

("..." and friends is a somewhat different kettle of fish which I don't want to go into just now.)


> There is another mention of `...` in section 4.3.2 and it does not
> explain some things, such as under what circumstances one would get a
> "`...` used in incorrect context" error.
> Peter
>>> Thanks.
>>> Just so I have my mental model correct, I'm gathering that missing/``
>>> is a symbol that the interpreter has a special rule for -- evaluating
>>> it raises an error, as opposed to objects that evaluate to themselves
>>> or variable names that evaluate to objects.
>>> Does the same sort of thing explain the behavior of `...`? When the
>>> interpreter comes across `...` in the arguments during evaluation of a
>>> call, it trips a special argument-interpolating behavior?

Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com

More information about the R-devel mailing list