I'm new to R and have a large data set where I need to check to see if one of the two values exceeds a threshold; if it does, I need to count it, and if it doesn't I ignore that value. 

I have to iterate through several columns, but I run into the issue where my if statement only checks the first value. A simple example would have the columns `id`, `val1`, `val2`, `val3`. If `val1` or `val2` are greater than a threshold, then I would count `val3` otherwise ignore. My data set is called `data`.

```
id val1 val2 val3
1  .4    4    10
2   5    5    11
3   2    2    1
4   6    1    10
5   2    100  4

```

My code is:

```
if(data$val1 > 5 | data$val2 > 5){sum(data$val3>5)}

```

The issue is that it only checks the first row. How can I iterate through every row?