Compare Two Vectors

To see if two vectors are identical:

> identical(c(1,3,5),c(5,3,1))
[1] FALSE
> identical(c(1,3,5),c(1,3,5))
[1] TRUE
> c(1,3,5)==c(1,3,5)
[1] TRUE TRUE TRUE

Note that the elements in a vector is ordered.  The values in different order means the definition of the two vectors are different.

The comparison operators are used to compare the individual values  of two vector:

==
>=
<= >
<
!=

See: Logical Data

Leave a comment