openplantpathology / Mungbean_PM

A meta-analysis of mungbean powdery mildew control fungicide efficacy trials
https://openplantpathology.github.io/Mungbean_PM/
Creative Commons Zero v1.0 Universal
1 stars 0 forks source link

Cluster application times #12

Closed adamhsparks closed 4 years ago

adamhsparks commented 4 years ago

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

PaulMelloy commented 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"

adamhsparks commented 4 years ago

Ah, it did? Good catch.

I'm trying to follow where your code fits what I did?

adamhsparks commented 4 years ago

I've fixed the code in my branch to address the issue.

PaulMelloy commented 4 years ago

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"
    )
  )
PaulMelloy commented 4 years ago

Code is incorporated into the chapter 'Prepare data'.