Skip to content

Testing if all elements are equal in a vector/matrix

3 messages · Vincent Goulet, Patrick Burns, robin hankin

#
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.
[1] TRUE
[1] TRUE

Best,

Vincent
#
How about

diff(range(x)) < tolerance

Patrick Burns
patrick at 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:

            
#
Hi

library(magic)
?minmax


[
the basic idea is min(x) == max(x)
]


best wishes


Robin
On 29 Aug 2005, at 20:35, Vincent Goulet wrote:

            
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743