#' Function to produce the list of non-reporting countries.
#'
#' @param collection_path String with path where single-year report directories
#' are stored.
#'
#' @param prefix String with report directory name prefix without trailing
#' underscore. By default NULL.
#'
#' @return A table with countries/years where the cell is 9 if the country
#' does not report completely for that year, 1 if it does not report
#' imports, 2 if it does not report exports.
#' @export
#' @import dplyr
#' @examples
#' \dontrun{
#' ts_non_reporters("/mnt/storage/sws_share/sas", "complete_tf_cpc")
#' }
#'
ts_non_reporters <- function(collection_path = NULL, prefix = NULL) {
elems <- c("flows_to_mirror_raw")
extract_rprt_elem(collection_path, prefix, elems) %>%
bind_rows() %>%
ungroup() %>%
dplyr::select(area, flow, name, year) %>%
group_by(area, year) %>%
dplyr::mutate(n = n()) %>%
ungroup() %>%
dplyr::mutate(missing = ifelse(n < 2, flow, 9)) %>%
rename_(non_rep_area = ~ area,
non_rep_name = ~ name) %>%
group_by(non_rep_area, non_rep_name, year) %>%
dplyr::summarise(missing = max(missing)) %>%
tidyr::spread(year, missing, fill = '')
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.