I have a vector e.g. like this:
vec <- c(6, 6, 10, 13, 13, 15, 15, 15, 15, 16, 16, 19)
I want now the positions of the elements which occur only once:
3, 12
Unique only ignores the values when they already have occurred.
Another option:
which(!(vec %in% vec[duplicated(vec)]))
#[1] 3 12
you can try this
which(vec %in% names(table(vec))[table(vec)==1] )
# 3 12
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With