curbholes curbholes -3 years ago 129
R Question

R: Find position of first value greater than X in a vector

In R: I have a vector and want to find the position of the first value that is greater than 100.

Answer Source
# Randomly generate a suitable vector
v <- sample(50:150, size = 50, replace = TRUE)

min(which(v > 100))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download