I have a 1 X 1000 vector = x of numbers from 1 to 1000, and a certain function = y into which I plug in these numbers, resulting in a 1 x 1000 vector of results. I would like for R to return the value of y at which the function is greater than a certain number. How can this be done?
2 Answers
res[ which(res > threshold)[1] ] #........ 2 Comments
JeremyS
doesn't this return the value of x at which y is above the threshold? But the question asks for the value of y ... (or does it?), also this will be the FIRST value of x at which y is above the threshold. It's a really ambiguous question actually.
IRTFM
I edited it to be the y-value under assumption that
res was f(x), but agree it is unclear exactly what was meant.