Consider the following vector a
a <- c(NULL, 1, 2, "A", NULL, NA)
I am trying to identify the positions of NULL in the vector. However, NULL is not a string. I am wondering why is.null does not work similar to is.na which returns the positions of the NAs in the vector.
> is.na(a)
[1] FALSE FALSE FALSE TRUE
> is.null(a)
[1] FALSE
The function
is.nullis used to check whether an object is identical toNULL. TheNULLvalues are not part of the vector, they are “nothing”.Hence your vector does not include any
NULLs but the other values only:The information about the
NULLs you used to create the vector is lost and cannot be retrieved.