[R] test whether all elements of a vector are identical

Jannis bt_jannis at yahoo.de
Thu Dec 16 15:17:46 CET 2010


Dear list,


this might be an easy one, but I could figure out a solution (or how to 
google the right term).

Is there any way to test whether all elements of a vector are identical?

For numeric vectors I would use

sum(diff(vector)==0)==0

but I have character vectors. Any Ideas?

Cheers
Jannis



More information about the R-help mailing list