I would like to find the minimum value a of vector but without including certain value
ex :
a <- c(1, 2, 3, 4, 5 ,-9999 ,7 ,8 ,9)
And I want to avoid values 1 and -9999. So the answer here would be 2.
I would like to find the minimum value a of vector but without including certain value
ex :
a <- c(1, 2, 3, 4, 5 ,-9999 ,7 ,8 ,9)
And I want to avoid values 1 and -9999. So the answer here would be 2.
We can use setdiff
to include only those elements which we want and find the 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)