r - Find the minimum of a vector ignoring certain numbers -
this question has answer here:
i find minimum value of vector without including value
ex :
a <- c(1, 2, 3, 4, 5 ,-9999 ,7 ,8 ,9)
and want avoid values 1 , -9999. answer here 2.
we can use setdiff
include elements want , find minimum among them.
min(setdiff(a, ignore)) #[1] 2
data
a <- c(1, 2, 3, 4, 5 ,-9999 ,7 ,8 ,9) ignore <- c(1, -9999)
Comments
Post a Comment