Country count metric update (noted in email)
@petergpython Previously noted issue in email. The count of countries metric is updated from old code to new code below.
# 5. Number of countries where germplasm collected (excluding certain SAMPSTAT)
country_count <- combined_allcrops %>%
filter(!(SAMPSTAT %in% c(400:499, 500, 600))) %>%
group_by(Crop_strategy) %>%
summarise(unique_countrycount = n_distinct(ORIGCTY), .groups = "drop")
This update excludes missing SAMPSTAT by using between() for the 400–499 range and removes blank ORIGCTY before counting unique countries by filtering to remove blank or NAs in ORIGCTY.
UPDATED
# 5. Number of countries where germplasm collected (excluding certain SAMPSTAT)
country_count <- combined_allcrops %>%
filter(!is.na(SAMPSTAT) & !(between(SAMPSTAT, 400, 499) | SAMPSTAT %in% c(500, 600))) %>% #excludes rows with SAMPSTAT=NA, or in 400–499, 500, or 600
filter(!is.na(ORIGCTY), ORIGCTY != "") %>% #drop missing/blank countries so they aren't counted
group_by(Crop_strategy) %>%
summarise(unique_countrycount = n_distinct(ORIGCTY), .groups = "drop")