0

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 2

2
 res[ which(res > threshold)[1] ] #........ 
Sign up to request clarification or add additional context in comments.

2 Comments

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.
I edited it to be the y-value under assumption that res was f(x), but agree it is unclear exactly what was meant.
1

If you call the result from function y res

res_over_certain_number <- res[res > certain_number] 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.