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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -