I have x
as
x <- c("7", "2", "3", "8", "8")
I want output
[1] "2" "3" "8"
and remove one of 8 and 7. Hence removing one of largest two numbers.
Here's a possibility with match()
.
x[-match(tail(sort(unique(x)), 2), x)]
# [1] "2" "3" "8"
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