Skip to content
Prev 153275 / 398500 Next

Detecting duplicate values

On Thu, 14 Aug 2008, Steven McKinney wrote:

            
Caveat:

  length(unique( c(1, NA )))
[1] 2
which may not be what Kevin wants.

Alternatives:

 	length( na.omit( unique( c(1, NA ) )) ) == 1

 	!isTRUE( any( a[1] != a[-1] )

HTH,

Chuck
Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901