I'm new in R and I'm struggling with this problem: I want to evaluate values in column A and get the position of the first non-zero value in that column. Then, I want to obtain the value in the position found but in column B. This would need to happen in a data frame similar to this one.
| Column A | Column B |
|---|---|
| 0 | 1998 |
| 0 | 1997 |
| 2 | 1996 |
| 3 | 1995 |
So the output should be: 1996.
I've tried using match() without success. Thank you in advance.