Skip to content

How to preserve NULL in vector

2 messages · Daren Tan, Duncan Murdoch

#
I have a vector containing NULL. Referencing to that NULL gives me NA
instead, which disrupt my codes. How can i preserve NULL as it is ?
[1] 1
[1] 2
[1] NA
#
On 4/6/2009 9:24 AM, Daren Tan wrote:
NULL is not a numeric value, so you can't put it in a numeric vector. 
When you tried, it got converted to the numeric value NA.

You can have a list containing NULL, and lists are vectors, but 
functions that expect *numeric* vectors generally won't work with them.

Duncan Murdoch