Re: [R] problem with all/all.equal

From: MacQueen, Don <macqueen1_at_llnl.gov>
Date: Wed, 13 Apr 2011 13:49:19 -0700


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:

   length(unique(x))==1

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

-Don

-- 
Don MacQueen

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





-----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


>Hi!
>
>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?
>
>Thanks,
>Laura
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>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 Wed 13 Apr 2011 - 20:55:03 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 Wed 13 Apr 2011 - 21:20:30 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.

list of date sections of archive