Skip to content
Back to formatted view

Raw Message

Message-ID: <BANLkTi=TiXLM-Sb5dRj8=YnZL871+zSPTg@mail.gmail.com>
Date: 2011-04-06T22:32:06Z
From: Peter Langfelder
Subject: problem with all/all.equal
In-Reply-To: <BANLkTim9PfFYU6iy7_wL6=auyX6424a9GA@mail.gmail.com>

On Wed, Apr 6, 2011 at 3:09 PM, Laura Smith <smithlaura937 at gmail.com> wrote:
> 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
>>

all looks at a logical vector (or two), and all.equal compares two
objects. For your purposes, you can ask whether

all (x==x[1])

for example.

Peter