With the following dataframe, I would like to filter out rows based on two conditions. If the daily temperature is less than 41 I would like to extract the epi temperature, if it is >= 41 I would like to extract the meta temperature.
df <- data.frame(day = c(1, 1, 1, 2, 2, 2),
temperature = c(40, 39, 39, 45, 38, 30),
strata = c("epi", "meta", "hypo", "epi", "meta", "hypo"))
desired output:
day temperature strata
1 40 epi
2 38 meta
I cant quite wrap my head around how to code this using tidyverse.