[R] Testing for numeric(0)

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Thu Jul 17 10:33:22 CEST 2003


Søren Højsgaard wrote:
> Hi all, Can anyone tell me how to test for numeric(0) ?

 > foo <- numeric(0)
 > length(foo)
[1] 0
 > is.numeric(foo)
[1] TRUE

  so:

  is.numeric0 <- function(x){length(x)==0 & is.numeric(x)}

seems to do the trick....

Baz




More information about the R-help mailing list