Reputation: 1
I have vectors:
a <- c(1,2,4,5,6)
b <- c(2,4,5)
A want to extract values from 'a' which are not in 'b', so desired output is:
1,6
How could i do that?
Upvotes: 0
Views: 56
Reputation: 887951
We can use setdiff
setdiff(a, b)
#[1] 1 6
Or if there are duplicates
library(vecsets)
vsetdiff(a, b)
Or using %in%
and !
a[! a %in% b]
Upvotes: 2