The goal of CME.assistant is to share reusable helper functions within the CME team. Also feel free to download, further revise and compile locally.
options(rmarkdown.html_vignette.check_title = FALSE)
library(CME.assistant)
#> Loading required package: data.table
Choose output format among raw, long, wide_year and wide_ind, default to “long”
* The long-format dataset contains Official Name, ISO3Code, Indicator, Year, Quantile, Sex * The function will output all available indicators in the dataset * Optional: subset by country ISO (c_iso
) or year (year_range
)
get.CME.UI.data
# without supplying dir_file, by default returns the published IGME 2020 final
# results
<- get.CME.UI.data(use_IGME_year = 2020)
dt_1 #> Indicators:U5MR, IMR, NMR, Under.five.Deaths, Infant.Deaths, Neonatal.Deaths
head(dt_1)
#> OfficialName ISO3Code Indicator Year Quantile Sex Value
#> 1: Afghanistan AFG IMR 1990 Lower Total 111.2
#> 2: Afghanistan AFG IMR 1990 Median Total 120.4
#> 3: Afghanistan AFG IMR 1990 Upper Total 130.9
#> 4: Afghanistan AFG IMR 1991 Lower Total 108.2
#> 5: Afghanistan AFG IMR 1991 Median Total 116.8
#> 6: Afghanistan AFG IMR 1991 Upper Total 126.2
# can read final output file from Dropbox for any indicator
# loading Dropbox files requires access to corresponding files
<- load.final_dir()
dir_list <- get.CME.UI.data(dir_file = dir_list$dir_female_2020)
dt_2 head(dt_2)
<- file.path(CME.assistant::get.IGME.dir(2020),
dir_cqt_files "figData/cqt_backup")
list.files(dir_cqt_files)
<- get.dt.cqt(dir_cqt_files)
dt_cqt table(Shortind, Sex)]
dt_cqt[, # table to be added into the profile by country:
<- get.table.by.iso(iso0 = "AFG") dt1
Automatically point to the latest file using the date in file names
<- load.IGMEinput.dir()
input_dirs <- get.dir_U5MR(input_dirs$dir_IGME_20)
dir_U5MR <- get.dir_IMR(input_dirs$dir_IGME_20)
dir_IMR <- get.dir_NMR(y5 = TRUE) # either 5-year or not
dir_NMR <- get.dir_gender(plotting = TRUE) # either dataset for plotting or modeling dir_gender
get.match
# a helpful function to revise variable, you can provide a __new_list__ to define the labels
get.match(c("a","b", "c"), new_list = list("a" = "new label 1",
"b" = "new label 2"))
#> [1] "new label 1" "new label 2" "c"
UNICEF_colors
str(UNICEF_colors)
#> List of 5
#> $ UNICEF_blue : chr "#1CABE2"
#> $ cp_UNICEF_seq : chr [1:8] "#002759" "#00377D" "#0058AB" "#0083CF" ...
#> $ cp_UNICEF_div : chr [1:10] "#002759" "#0058AB" "#1CABE2" "#69DBFF" ...
#> $ cp_UNICEF_qua : chr [1:10] "#0058AB" "#1CABE2" "#00833D" "#80BD41" ...
#> $ cp_UNICEF_grays: chr [1:5] "#333333" "#6B6B6B" "#B3B3B3" "#D7D7D7" ...