[R] Cause of error assigning NULL to element of a vector
marc_schwartz at me.com
Wed May 24 20:51:41 CEST 2017
> On May 24, 2017, at 1:30 PM, Ramnik Bansal <ramnik.bansal at gmail.com> wrote:
> What is the cause of the error below ?
>> y <- 1
>> y <- NULL
> Error in y <- NULL : replacement has length zero
You are attempting to assign NULL, which is a zero length special object of its own kind, to a specific element in the vector object 'y' and that cannot be done.
You can assign NULL to 'y':
y <- NULL
BUT, 'y' is not a vector in that case:
Nor can a vector contain multiple NULLs:
y <- c(NULL, NULL, NULL)
y <- c(1, NULL, 1)
 1 1
Perhaps reviewing ?NULL as well as:
might also provide some insights.
More information about the R-help