I need to calculate the max and min of the wave height according to the direction from which it comes, that is to say, I have two variables:
- Hs (wave height)
- Direction (direction of the swell)
And I need to know the maximum wave height for waves with a direction between 11.25 and 33.75 degrees.
For now, use the function:
Max (Hs [Direction [11.25: 33.75]))
But I do not agree the result with the data that I have.
The answer from @LAP is absolutely correct, but you can also use the
dplyr
package to get both themax
andmin
.First let's create some sample data.
Now let's calculate.
Assume your dataframe is called
df
, your variables are calledHs
andDirection
, you can useto get the maximum of all
Hs
values within the defined value range ofDirection
.If you, like me, dislike the necessity to define both lower and upper bounds of the interval separately, you can use this neat function (which I found here):
Then use