RStats tip #2: avoid missing(), prefer NULL

RStats tip #2: avoid missing(), prefer NULL

Functions in R often take optional values, one way to implement this is using the missing() function.

missing() returns TRUE or FALSE if the user passed a value to an argument. This behavior works well interactively.

However functions which use missing() are much more challenging to call programmatically.

An alternative, using NULL to denote missing values, in contrast is simple to call programmatically and better reveals that the argument is option.

Jim Hester
Software Engineer

I’m a Senior Software Engineer at Netflix and R package developer.