Skip to content
Prev 5824 / 398506 Next

no warning with NULL component in data.frame

Dear all,

I am a bit surprised that R does not give a warning (or a message error)
when calling, in a data.frame (or a list), an element that does not exist:
my.var1 my.var2
1       1       3
2       2       4
NULL
[1] 1 2

I would expect a message saying that my.var3 is NULL when trying to
manipulate it. For instance, sum() gives:
[1] 0

(the same with any suffix after $) which is again surprising since, to me,
the element does not exist.

Is there a reason for this?

Best,

Emmanuel Paradis
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._