Check whether two vectors contain the same (unordered) elements in R

前端 未结 5 1316
予麋鹿
予麋鹿 2021-01-01 11:24

I\'d like to check whether two vectors contain the same elements, even if they\'re not ordered the same. For example, the function (let\'s call it SameElements)

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 12:01

    I think you can use setequal(a,b)

    Updated update setequal checks if two vectors are composed of the same elements but it does not check if these elements have the same occurrences in each vector.

提交回复
热议问题