# Ranking
ranking_df <-
result_indicator_df %>%
# to spread number of occurrence indicator values per year
select(-aoo) %>%
spread(key = eyear, value = occ, sep = "occ_") %>%
left_join(result_indicator_df %>%
# to spread AOO indicator values per year
select(-occ) %>%
spread(key = eyear, value = aoo, sep = "aoo_"),
by = c("taxonKey", "canonicalName")) %>%
rename_at(vars(starts_with("eyear")), ~str_remove(., pattern = "eyear")) %>%
group_by(taxonKey, canonicalName) %>%
arrange(
desc(aoo_2017),
desc(occ_2017),
desc(aoo_2016),
desc(occ_2016),
desc(aoo_2015),
desc(occ_2015)) %>%
select(taxonKey, canonicalName,
aoo_2017, occ_2017,
aoo_2016, occ_2016,
aoo_2015, occ_2015)
This code results in the ranking here below, based on the test data (19 species):
So, you can read the ranking from left to right, like :1st_place_medal: :2nd_place_medal: :3rd_place_medal: ... up to 6th place "medal" at Olympic Games.
Once we have a value per indicator (and per year), we apply this ranking (as described in https://github.com/trias-project/indicators/issues/49#issuecomment-509530528):
This code results in the ranking here below, based on the test data (19 species):
So, you can read the ranking from left to right, like :1st_place_medal: :2nd_place_medal: :3rd_place_medal: ... up to 6th place "medal" at Olympic Games.