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 <- 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 isTRUE(logical(0)) # FALSE but, on the other hand, 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? 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 -3170 FAX E-mail: gkerns at ysu.edu http://www.cc.ysu.edu/~gjkerns/
Try length:> x <- c() > xNULL> length(x)[1] 0 On Mon, Nov 24, 2008 at 12:41 PM, G. Jay Kerns <gkerns at ysu.edu> 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 borne out by > > 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 > > isTRUE(logical(0)) # FALSE > > but, on the other hand, > > 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? > > 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 > -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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
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. This is borne out by > > 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 > > isTRUE(logical(0)) # FALSE > > but, on the other hand, > > 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? > > Thanks in advance for any insight you may have.Why not just check the length? length(x) == 0 will be true for NULL, and all of the empty vectors as well. Duncan Murdoch
You seem to want: length(x) == 0 Patrick Burns patrick at burns-stat.com +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 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 <- 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 > > isTRUE(logical(0)) # FALSE > > but, on the other hand, > > 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? > > 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 > -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. > > >
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), > logical(0), etc. This is borne out by > > y <- letters[1:3] > z <- letters[4:6] > intersect(y,z) > > which, of course, is non-NULL: > > is.null(character(0)) # FALSEIn the above (and below) cases, would not (length(x)==0) do? Ted.> 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 > > isTRUE(logical(0)) # FALSE > > but, on the other hand, > > 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? > > Thanks in advance for any insight you may have. > > Best, > Jay-------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 24-Nov-08 Time: 18:15:31 ------------------------------ XFMail ------------------------------
Dear Everybody, Thanks, length() is the answer. Best, Jay On Mon, Nov 24, 2008 at 1:15 PM, Ted Harding <Ted.Harding at manchester.ac.uk> 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, 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 <- letters[4:6] >> intersect(y,z) >> >> which, of course, is non-NULL: >> >> is.null(character(0)) # FALSE > > In the above (and below) cases, would not > > (length(x)==0) > > do? > Ted. > >> 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 >> >> isTRUE(logical(0)) # FALSE >> >> but, on the other hand, >> >> 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? >> >> Thanks in advance for any insight you may have. >> >> Best, >> Jay > > -------------------------------------------------------------------- > E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> > Fax-to-email: +44 (0)870 094 0861 > Date: 24-Nov-08 Time: 18:15:31 > ------------------------------ XFMail ------------------------------ >-- *************************************************** 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/
> > 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(x) == 0 do the trick? Or am I missing something? Best regards, Stefan Evert [ stefan.evert at uos.de | http://purl.org/stefan.evert ]
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 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 <- 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 isTRUE(logical(0)) # FALSE but, on the other hand, 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? 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 -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.
?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(0), > logical(0), etc. This is borne out by > > 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 > > isTRUE(logical(0)) # FALSE > > but, on the other hand, > > 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? > > 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 > -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. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
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(), character() ))) => 9. -s On Mon, Nov 24, 2008 at 12:41 PM, G. Jay Kerns <gkerns at ysu.edu> 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 borne out by > > 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 > > isTRUE(logical(0)) # FALSE > > but, on the other hand, > > 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? > > 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 > -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. >
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 borne out by > > 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)You could use length(x) == 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 > > isTRUE(logical(0)) # FALSE > > but, on the other hand, > > 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? > > 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 > -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.-- Niels Richard Hansen Associate Professor Department of Mathematical Sciences University of Copenhagen Universitetsparken 5 2100 Copenhagen ? Denmark +45 353 20783
length() /Henrik On Mon, Nov 24, 2008 at 9:41 AM, G. Jay Kerns <gkerns at ysu.edu> 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 borne out by > > 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 > > isTRUE(logical(0)) # FALSE > > but, on the other hand, > > 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? > > 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 > -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. >
Rainer Tischler
2008-Nov-25 00:37 UTC
[R] unsupervised dimensionality reduction retaining the attributes
Dear all, I'm looking for an unsupervised dimensionality reduction method for large-scale data sets (> 40.000 attributes) which retains the original attribute vectors (i.e. "unsupervised feature selection"). Until now I have only found several unsupervised dimensionality reduction methods which use derived features (transforming instead of selecting features) and some very simple variance filters (e.g. fold change filtering). Is anybody aware of a more advanced method, which can score feature subsets instead of just single features and is fast enough for high-dimensional data sets (like the greedy CFS-method for supervised feature subset selection, but in an unsupervised setting)? If there is no R-package for this, I would also be glad if someone could point me to a good research paper about this topic. I have no labels for my data; hence, supervised feature selection is not an option for me. many thanks in advance, Rainer
Dear Jay, length(x) will return zero for all these (vector) examples, and is quite readable in code. (You might have seen code such as if(length(x)) { blah } which uses this idea.) Does this cover all your use cases?> x <- c()> class(x)[1] "NULL"> length(x)[1] 0> y <- letters[1:3] > z <- letters[4:6] > x <- intersect(y,z)> class(x)[1] "character"> length(x)[1] 0> y <- 1:3 > z <- 4:6 > x <- intersect(y,z)> class(x)[1] "integer"> length(x)[1] 0>HTH Steven McKinney Statistician Molecular Oncology and Breast Cancer Program British Columbia Cancer Research Centre email: smckinney +at+ bccrc +dot+ ca tel: 604-675-8000 x7561 BCCRC Molecular Oncology 675 West 10th Ave, Floor 4 Vancouver B.C. V5Z 1L3 Canada -----Original Message----- From: r-help-bounces at r-project.org on behalf of G. Jay Kerns Sent: Mon 11/24/2008 9:41 AM To: r-help at 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 depending on the vector's mode, namely, numeric(0), character(0), logical(0), etc. This is borne out by 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 isTRUE(logical(0)) # FALSE but, on the other hand, 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? 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 -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.
Dear Steven,> length(x)> Does this cover all your use > cases?Yes, and thanks again to everybody else who later replied. I had falsely imagined something so much more complicated...!? Next time, I will wait 8*runif(1) before posting. :-) Best, Jay> HTH > > Steven McKinney > > Statistician > Molecular Oncology and Breast Cancer Program > British Columbia Cancer Research Centre > > email: smckinney +at+ bccrc +dot+ ca > > tel: 604-675-8000 x7561 > > BCCRC > Molecular Oncology > 675 West 10th Ave, Floor 4 > Vancouver B.C. > V5Z 1L3 > Canada > > > > > -----Original Message----- > From: r-help-bounces at r-project.org on behalf of G. Jay Kerns > Sent: Mon 11/24/2008 9:41 AM > To: r-help at 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 depending on the vector's mode, namely, numeric(0), character(0), > logical(0), etc. This is borne out by > > 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 > > isTRUE(logical(0)) # FALSE > > but, on the other hand, > > 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? > > 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 > -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. > >-- *************************************************** 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/