首页 > 解决方案 > Issue in Not operator

问题描述

Can anyone please help me. Not sure what wrong I am doing here. As per the code I should get the result as "A" right? Or Am i missing something?

> asd <- c("A")
> asd1 <- c("B","V")
> asd[asd %in% !(asd %in% asd1)]
character(0)

标签: r

解决方案


A simpler solution will return the desired result, you do not need to use %in% twice:

asd[!(asd %in% asd1)]
[1] "A"

推荐阅读