From: Patrick Burns <pburns_at_pburns.seanet.com>

Date: Tue 30 Aug 2005 - 07:22:14 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Aug 30 07:29:01 2005

Date: Tue 30 Aug 2005 - 07:22:14 EST

How about

diff(range(x)) < tolerance

Patrick Burns

patrick@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")

Vincent Goulet wrote:

>Is there a canonical way to check if all elements of a vector or matrix are

*>the same? Solutions below work, but look hackish to me.
**>
**>
**>
**>>x <- rep(1, 10)
**>>all(x == x[1]) # == operator does not provide for small differences
**>>
**>>
**>[1] TRUE
**>
**>
**>>isTRUE(all.equal(x, rep(x[1], length(x)))) # ugly
**>>
**>>
**>[1] TRUE
**>
**>Best,
**>
**>Vincent
**>
**>
*

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Aug 30 07:29:01 2005

*
This archive was generated by hypermail 2.1.8
: Sun 23 Oct 2005 - 16:02:50 EST
*