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:
Max (Hs [Direction [11.25: 33.75]))
The answer from @LAP is absolutely correct, but you can also use the
dplyr package to get both the
First let's create some sample data.
df <- data.frame(Hs = rnorm(327), Direction = runif(327, 0, 364))
Now let's calculate.
library(dplyr) df %>% filter(Direction >= 11.25 & Direction <= 33.75) %>% summarise(max(Hs), min(Hs))