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
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
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
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
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(),
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
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
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(
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
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'
?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
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
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
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
14 matches
Mail list logo