[R] problem with all/all.equal

MacQueen, Don macqueen1 at llnl.gov
Wed Apr 13 22:49:19 CEST 2011

The help pages for identical() and all.equal() have information that will
make it clear why they don't do what you want.

In the meantime, I tend to use a construct such as:


But be careful if x is not a vector.
No doubt there are other ways.


Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550

-----Original Message-----
From: Laura Smith <smithlaura937 at gmail.com>
Date: Wed, 6 Apr 2011 15:09:14 -0700
To: "r-help at r-project.org" <r-help at r-project.org>
Subject: [R]  problem with all/all.equal

>In a function, I may have an instance in which all elements are equal.
>> x <- rep(1,5)
>> x
>[1] 1 1 1 1 1
>> identical(x)
>Error in .Internal(identical(x, y, num.eq, single.NA, attrib.as.set)) :
>  'y' is missing
>> all.equal(x)
>Error in is.expression(x) : 'x' is missing
>I don't care what particular value it is, I just want to know if they are
>all equal.
>What am I doing wrong, please?
>    [[alternative HTML version deleted]]
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list