Re: [R] how to test for the empty set

2008-11-25 Thread Niels Richard Hansen
G. Jay Kerns wrote: > Dear R-help, > > I first thought that the empty set (for a vector) would be NULL. > > x <- c() > x > > However, the documentation seems to make clear that there _many_ empty > sets depending on the vector's mode, namely, numeric(0), character(0), > logical(0), etc. This is

Re: [R] how to test for the empty set

2008-11-24 Thread Daniel Malter
ED] Im Auftrag von G. Jay Kerns Gesendet: Monday, November 24, 2008 12:41 PM An: r-help@r-project.org Betreff: [R] how to test for the empty set Dear R-help, I first thought that the empty set (for a vector) would be NULL. x <- c() x However, the documentation seems to make clear that there _ma

Re: [R] how to test for the empty set

2008-11-24 Thread jim holtman
Try length: > x <- c() > x NULL > length(x) [1] 0 On Mon, Nov 24, 2008 at 12:41 PM, G. Jay Kerns <[EMAIL PROTECTED]> wrote: > Dear R-help, > > I first thought that the empty set (for a vector) would be NULL. > > x <- c() > x > > However, the documentation seems to make clear that there _many_ e

Re: [R] how to test for the empty set

2008-11-24 Thread Duncan Murdoch
On 24/11/2008 12:41 PM, G. Jay Kerns wrote: Dear R-help, I first thought that the empty set (for a vector) would be NULL. x <- c() x However, the documentation seems to make clear that there _many_ empty sets depending on the vector's mode, namely, numeric(0), character(0), logical(0), etc. T

Re: [R] how to test for the empty set

2008-11-24 Thread Stavros Macrakis
Doesn't length(x)=0 do the trick? In general, the cardinality of a set represented as a vector or list of elements is length(unique(x)). Unique uses `identical` as its equivalence relation, so length( unique( list( 1L, 1.0, 1+0i, as.logical(NA), as.character(NA), as.numeric(NA), NULL, logical(),

Re: [R] how to test for the empty set

2008-11-24 Thread Patrick Burns
You seem to want: length(x) == 0 Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") G. Jay Kerns wrote: Dear R-help, I first thought that the empty set (for a vector) would be NULL. x <- c() x However, the

Re: [R] how to test for the empty set

2008-11-24 Thread Ted Harding
On 24-Nov-08 17:41:25, G. Jay Kerns wrote: > Dear R-help, > I first thought that the empty set (for a vector) would be NULL. > > x <- c() > x > > However, the documentation seems to make clear that there _many_ empty > sets depending on the vector's mode, namely, numeric(0), character(0), > logic

Re: [R] how to test for the empty set

2008-11-24 Thread Stefan Evert
all.equal(x, character(0)) # TRUE This would seem to be the solution, but am I missing something? and in particular, is there an elegant way to check in the case that the mode of the vector is not already known? If you do not care about the mode of the vector, wouldn't simply length(

Re: [R] how to test for the empty set

2008-11-24 Thread G. Jay Kerns
Dear Everybody, Thanks, length() is the answer. Best, Jay On Mon, Nov 24, 2008 at 1:15 PM, Ted Harding <[EMAIL PROTECTED]> wrote: > On 24-Nov-08 17:41:25, G. Jay Kerns wrote: >> Dear R-help, >> I first thought that the empty set (for a vector) would be NULL. >> >> x <- c() >> x >> >> However, th

Re: [R] how to test for the empty set

2008-11-24 Thread Henrik Bengtsson
length() /Henrik On Mon, Nov 24, 2008 at 9:41 AM, G. Jay Kerns <[EMAIL PROTECTED]> wrote: > Dear R-help, > > I first thought that the empty set (for a vector) would be NULL. > > x <- c() > x > > However, the documentation seems to make clear that there _many_ empty > sets depending on the vector'

Re: [R] how to test for the empty set

2008-11-24 Thread Charles C. Berry
?length Chuck On Mon, 24 Nov 2008, G. Jay Kerns wrote: Dear R-help, I first thought that the empty set (for a vector) would be NULL. x <- c() x However, the documentation seems to make clear that there _many_ empty sets depending on the vector's mode, namely, numeric(0), character

Re: [R] how to test for the empty set

2008-11-24 Thread Steven McKinney
behalf of G. Jay Kerns Sent: Mon 11/24/2008 9:41 AM To: r-help@r-project.org Subject: [R] how to test for the empty set Dear R-help, I first thought that the empty set (for a vector) would be NULL. x <- c() x However, the documentation seems to make clear that there _many_ empty sets depen

Re: [R] how to test for the empty set

2008-11-24 Thread G. Jay Kerns
r B.C. > V5Z 1L3 > Canada > > > > > -Original Message- > From: [EMAIL PROTECTED] on behalf of G. Jay Kerns > Sent: Mon 11/24/2008 9:41 AM > To: r-help@r-project.org > Subject: [R] how to test for the empty set > > Dear R-help, > > I first thought that the

[R] how to test for the empty set

2008-11-24 Thread G. Jay Kerns
Dear R-help, I first thought that the empty set (for a vector) would be NULL. x <- c() x However, the documentation seems to make clear that there _many_ empty sets depending on the vector's mode, namely, numeric(0), character(0), logical(0), etc. This is borne out by y <- letters[1:3] z <- le