From: Daniel Malter <daniel_at_umd.edu>

Date: Mon, 24 Nov 2008 14:57:44 -0500

cuncta stricte discussurus

G. Jay Kerns, Ph.D.

Associate Professor

Department of Mathematics & Statistics

Youngstown State University

Youngstown, OH 44555-0002 USA

Office: 1035 Cushwa Hall

Phone: (330) 941-3310 Office (voice mail)

-3302 Department

*-3170 FAX
*

E-mail: gkerns_at_ysu.edu

http://www.cc.ysu.edu/~gjkerns/

R-help_at_r-project.org 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.

R-help_at_r-project.org 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 Tue 25 Nov 2008 - 06:49:17 GMT

Date: Mon, 24 Nov 2008 14:57:44 -0500

Hi, any empty set has (or should have) length 0.

y <- letters[1:3]

z <- letters[4:6]

length(intersect(y,z))

Cheers,

Daniel

cuncta stricte discussurus

-----Ursprüngliche Nachricht-----

Von: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] Im
Auftrag von G. Jay Kerns

Gesendet: Monday, November 24, 2008 12:41 PM
An: r-help_at_r-project.org

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

I first thought that the empty set (for a vector) would be NULL.

y <- letters[1:3]

z <- letters[4:6]

intersect(y,z)

which, of course, is non-NULL:

is.null(character(0)) # FALSE

So, how can we test if a vector is, say, character(0)? The following doesn't (seem to) work:

x <- character(0)

x == character(0) # logical(0)

More snooping led to the following:

wiki.r-project.org/rwiki/doku.php?id=tips:surprises:emptysetfuncs

and at the bottom of the page it says "logical(0) is an empty set, thus is TRUE". However, I get

all.equal(x, character(0)) # TRUE

Thanks in advance for any insight you may have.

Best,

Jay

G. Jay Kerns, Ph.D.

Associate Professor

Department of Mathematics & Statistics

Youngstown State University

Youngstown, OH 44555-0002 USA

Office: 1035 Cushwa Hall

Phone: (330) 941-3310 Office (voice mail)

-3302 Department

http://www.cc.ysu.edu/~gjkerns/

R-help_at_r-project.org 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.

R-help_at_r-project.org 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 Tue 25 Nov 2008 - 06:49:17 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Tue 25 Nov 2008 - 07:30:29 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.
*