Code
library(writexl)
library(tidyverse)
library(gsheet)
library(lubridate)
Before creating the intervals, you need to verify whether the dates are in the correct format and ensure that the data is consistent across all studies
dat_all2=dat_all2 %>% filter(study!="106")
dat_all2 <- dat_all2 %>%
mutate(sowing = if_else(study == 150, as.Date("2024-11-01"), sowing))
trials_setup <- dat_all2 %>%
# filter(study != c(29, 30)) %>%
mutate(
sowing = as.Date(sowing, format = "%d-%m-%Y")
) %>%
mutate(
minus5 = sowing - 5,
plus90 = sowing + 90
)
The threshold you choose to classify epidemics and non-epidemics may vary. For example, you might use the median value, as it splits the dataset into epidemic and non-epidemic groups more evenly. Alternatively, you could select a threshold that makes sense in the field, taking into account crop damage and yield loss.
# A tibble: 194 × 2
# Groups: study [194]
study n
<dbl> <int>
1 1 1
2 2 1
3 3 1
4 4 1
5 5 1
6 6 1
7 7 1
8 8 1
9 9 1
10 10 1
# ℹ 184 more rows