[R] problem with all/all.equal
Peter Langfelder
peter.langfelder at gmail.com
Thu Apr 7 00:32:06 CEST 2011
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
More information about the R-help
mailing list