Excluding elements of a vector from another vector, not using setdiff

后端 未结 4 1198
面向向阳花
面向向阳花 2021-01-19 06:30

I have a character vector, and I want to exclude elements from it which are present in a second vector. I don\'t know how to work the negation in this case while still consi

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-19 07:27

    You're close

    vector[!vector %in% vector2]
    

    or, even though you said "not using setdiff"

    setdiff(vector, vector2)
    

提交回复
热议问题