Re: [R] if (NULL) is error?

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Sun 01 Oct 2006 - 17:17:17 GMT

On 10/1/2006 12:29 PM, Alberto Vieira Ferreira Monteiro wrote:
> Why this is not valid?
>
> test <- NULL
> if (test) "test"

The test part of an if statement should evaluate to a length 1 logical or numeric value. NULL is length zero.

The R Language Definition explains this (although it implies length > 1 is okay; in fact, that gives a warning).

Duncan Murdoch



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon Oct 02 03:23:24 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 01 Oct 2006 - 18:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.