Closed adamhsparks closed 4 years ago
I have been adding this data grouping to the master branch in 04_Prep_data.rmd. I noted that with the code supplied in your md above allocated the control treatments to late clusters.
I updated this with the following code
slim_PM_dat[slim_PM_dat$fungicide_ai == "control", c("fungicide_timing_1", "fungicide_timing_2", "fungicide_timing_3","cluster_1", "cluster_2","cluster_3")] <- "control"
Ah, it did? Good catch.
I'm trying to follow where your code fits what I did?
I've fixed the code in my branch to address the issue.
I updated the clustering code in your branch to handle NA
values.
mb <-
mb %>%
mutate(
cluster_1 = case_when(
is.na(fungicide_timing_1) ~ NA_character_,
fungicide_timing_1 < 0 ~ "Early",
fungicide_timing_1 >= 0 &
fungicide_timing_1 < 4 ~ "Recommended",
fungicide_timing_1 > 4 ~ "Late"
)
) %>%
mutate(
cluster_2 = case_when(
is.na(fungicide_timing_2) ~ NA_character_,
fungicide_timing_2 < 13 ~ "Early",
fungicide_timing_2 >= 13 &
fungicide_timing_2 < 17 ~ "Recommended",
fungicide_timing_2 > 17 ~ "Late"
)
) %>%
mutate(
cluster_3 = case_when(
is.na(fungicide_timing_3) ~ NA_character_,
fungicide_timing_3 < 14 ~ "Early",
fungicide_timing_3 == 14 ~ "Recommended"
)
)
Code is incorporated into the chapter 'Prepare data'.
I've updated my Rmd to cluster application times using Paul's new slim data.
Example in my branch for discussion. I've not yet committed any of this to Master aside from correcting the dates of application in 2018-19 season.
https://github.com/openplantpathology/Mungbean_PM/blob/Adam/Cluster%20Timing/MB_PM_data.md