[R] Nulls being coerced : Bug or design?
dwinsemius at comcast.net
Fri Jun 21 23:38:37 CEST 2013
On Jun 21, 2013, at 1:21 PM, Saptarshi Guha wrote:
> Consider the following transcript
>  10
>  NA NA NA NA NA NA NA NA NA 10
> Wouldn't one expect that x remain NULL despite the further additions (i.e
> the x$date, x) etc? Is coercing appropriate here?
This seems like a bizarre expectation. You really want x to remain NULL until the end of time? Perhaps you meant to say that after creation of a tenth entry for x that you wanted x to remain NULL (which it never was, since it didn't really exist). Or to have the display of missing values to be suppressed by the print function? Or were hoping the creation of an n-th item in x to _not_ create a vector of length n? Or that `x` be different than a multi-valued version of x[n]?
> x <- 1000
So you have apparently not realized that lists in R are actually vectors. .... by design. And the indexing a NULL value gives NULL rather than missing (NA):
x <- NULL
Actually I think the behavior for "[" when indexing is attempted with arguments greater than the length of a list or vector is not at all what I would have expected. That it would have seem to me to have deserved a NULL return:
Alameda, CA, USA
More information about the R-help