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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -