From h@wickh@m @ending from gm@il@com  Mon Jul 23 21:03:06 2018
From: h@wickh@m @ending from gm@il@com (Hadley Wickham)
Date: Mon, 23 Jul 2018 14:03:06 -0500
Subject: [Rd] Is NULL a vector?
Message-ID: <CABdHhvHuCuaytOP-5VOYO=5+fiQQPNFPYeeU-jJrN9=k_1t+yA@mail.gmail.com>

Hi all,

Would you generally consider NULL to be a vector? Base R functions are
a little inconsistent:

## In favour

``` r
identical(as.vector(NULL), NULL)
#> [1] TRUE

identical(as(NULL, "vector"), NULL)
#> [1] TRUE

# supports key vector vector generics
length(NULL)
#> [1] 0
NULL[c(3, 4, 5)]
#> NULL
NULL[[1]]
#> NULL
```

## Against

``` r
is.vector(NULL)
#> [1] FALSE

is(NULL, "vector")
#> [1] FALSE
```

## Abstentions

``` r
is.atomic(NULL)
#> [1] TRUE
# documentation states "returns NULL if x is of an atomic type (or NULL)"
# is "or" exclusive or inclusive?
```

Hadley

-- 
http://hadley.nz



[Rd] Is NULL a vector?
Hadley Wickham