Given a vector a=[1,2, 3.2, 4, 5] and an element x=3 In vector a, how to find the exact entry which is bigger than x? In R, is there any function to do that?
> a <- c(1,2, 3.2, 4, 5)
> x <- 3
> a[a > x]
[1] 3.2 4.0 5.0
> min(a[a > x])
[1] 3.2
the answer...
min(a[a>3])
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