### Examples Source: https://ilostat.github.io/Rilostat/reference/clean_ilostat_cache.html Example of how to use the clean_ilostat_cache function. ```R if (FALSE) { # \dontrun{ clean_ilostat_cache() } # } ``` -------------------------------- ### Get multiple datasets by reference area Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Example of downloading multiple datasets at once by providing a vector of reference area IDs. ```r dat <- get_ilostat(id = c('AFG_A', 'TTO_A'), segment = 'ref_area',quiet = TRUE) dplyr::count(dat, ref_area) ``` -------------------------------- ### Rilostat Package Documentation Example Source: https://ilostat.github.io/Rilostat/reference/Rilostat.html Example demonstrating how to check for recently added documentation. ```R if (FALSE) { # \dontrun{ # check which documentation have been recently added: # help(Rilostat) # https://ilostat.github.io/Rilostat/ } # } ``` -------------------------------- ### Examples Source: https://ilostat.github.io/Rilostat/reference/get_ilostat_toc.html Examples demonstrating how to use the `get_ilostat_toc` function with different parameters for segment, language, search, and fixed matching. ```R if (FALSE) { # \dontrun{ ## default segment by indicator, default lang English toc <- get_ilostat_toc() head(toc) toc <- get_ilostat_toc(segment = "ref_area", lang = "fr") head(toc) ## ## search on toc toc <- get_ilostat_toc(search = "education") head(toc) toc <- get_ilostat_toc(lang = "fr", search = "age") head(toc) toc <- get_ilostat_toc(segment = "ref_area", lang = "fr", search = "Albanie") toc toc <- get_ilostat_toc(segment = "ref_area", lang = "es", search = "Trimestral") head(toc) ## ## search multi on toc toc <- get_ilostat_toc(segment = "ref_area", lang = "fr", search = "Albanie|France", fixed = FALSE) head(toc) toc <- get_ilostat_toc(search = "youth|adult", fixed = FALSE) head(toc) ## } # } ``` -------------------------------- ### Examples Source: https://ilostat.github.io/Rilostat/reference/get_ilostat_dic.html Examples of how to use the get_ilostat_dic function. ```R if (FALSE) { # \dontrun{ tmp <- get_ilostat_dic("indicator") head(tmp) tmp <- get_ilostat_dic("classif1", lang = "fr") head(tmp) } # } ``` -------------------------------- ### Get multiple datasets by indicator using TOC Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Example of downloading multiple datasets by indicator, first retrieving a table of contents (TOC) and then using it to fetch the datasets. ```r toc <- get_ilostat_toc(search = 'CPI_', quiet = TRUE) dat <- get_ilostat(id = toc, segment = 'indicator', quiet = TRUE) dplyr::count(dat, indicator) ``` -------------------------------- ### Get a single dataset by indicator Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Example of how to retrieve a single annual dataset for a specific indicator using its ID. ```r dat <- get_ilostat(id = 'UNE_2UNE_SEX_AGE_NB_A', segment = 'indicator', quiet = TRUE) ``` -------------------------------- ### Rilostat Distribution Function Example Source: https://ilostat.github.io/Rilostat/reference/distribution_ilostat.html An example demonstrating how to use the distribution_ilostat function with a sample dataset and how to integrate it with other data manipulation functions. ```r if (FALSE) { # \dontrun{ dat <- get_ilostat("EMP_TEMP_SEX_STE_GEO_NB_A", cache = FALSE) dat_dist <- distribution_ilostat(dat, "classif1") dat_plus_dist <- mutate(dat, dist = distribution_ilostat(dat,"classif1", .keep=TRUE)) head(dat_dist) clean_ilostat_cache() } # } ``` -------------------------------- ### Get a single dataset by reference area Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Example of how to retrieve all annual data available for a specific reference area using its ID. ```r dat <- get_ilostat(id = 'ARM_A', segment = 'ref_area', quiet = TRUE) ``` -------------------------------- ### get_ilostat Examples Source: https://ilostat.github.io/Rilostat/reference/get_ilostat.html Demonstrates various ways to use the get_ilostat function, including downloading single and multiple datasets, filtering, caching, and advanced manipulation. ```R if (FALSE) { # \dontrun{ ############# get simple dataset dat <- get_ilostat("UNE_TUNE_SEX_AGE_NB_A") head(dat) dat <- get_ilostat("NZL_Q", segment = "ref_area") head(dat) dir.create(file.path(tempdir(), "r_cache")) dat <- get_ilostat("UNE_TUNE_SEX_AGE_NB_A", cache_dir = file.path(tempdir(), "r_cache")) head(dat) clean_ilostat_cache(cache_dir = file.path(tempdir(), "r_cache")) options(ilostat_update = TRUE) dat <- get_ilostat("UNE_TUNE_SEX_AGE_NB_A") head(dat) options(ilostat_update = FALSE) options(ilostat_cache_dir = file.path(tempdir(), "r_cache")) dat <- get_ilostat("UNE_TUNE_SEX_AGE_NB_A") clean_ilostat_cache() ############# get multiple datasets dat <- get_ilostat(c("CPI_ACPI_COI_RT_M", "CPI_ACPI_COI_RT_Q"), cache = FALSE) head(dat) toc <- get_ilostat_toc(search = "CPI_") head(toc) dat <- get_ilostat(toc, cache = FALSE) #id as a tibble ############# get datasets with filters dat <- get_ilostat(id = c("UNE_TUNE_SEX_AGE_NB_A", "EMP_TEMP_SEX_AGE_NB_A"), filters = list( ref_area = "FRA", classif1 = "_YGE15", time = "2016", sex = c("T", "SEX_F")), quiet = TRUE) head(dat) clean_ilostat_cache() ############# store in other format dir.create(file.path(tempdir(), "ilostat")) dat <- get_ilostat("UNE_TUNE_SEX_AGE_NB_A", cache_dir = file.path(tempdir(), "r_cache"), cache_format = "csv") dat <- get_ilostat("UNE_TUNE_SEX_AGE_NB_A", cache_dir = file.path(tempdir(), "r_cache"), cache_format = "dta") ############# advanced manipulation dat <- get_ilostat("UNE_TUNE_SEX_AGE_NB_A", cmd = "dat %>% count(ref_area)", quiet = TRUE) label_ilostat(dat, code = "ref_area") clean_ilostat_cache() } # } ``` -------------------------------- ### Examples of label_ilostat Source: https://ilostat.github.io/Rilostat/reference/label_ilostat.html Provides examples of how to use label_ilostat, including labeling a data frame and adding a specific label column. ```R if (FALSE) { # \dontrun{ dat <- get_ilostat("UNE_2UNE_SEX_AGE_NB_A", cache = FALSE) dat_lab <- label_ilostat(dat) head(dat_lab) # add just ref_area label require(tidyverse) dat <- get_ilostat("UNE_TUNE_SEX_AGE_NB_A") %>% mutate(ref_area.label = ref_area %>% label_ilostat( "ref_area", code = "all"), .after = ref_area) clean_ilostat_cache() } # } ``` -------------------------------- ### Get quarterly data with numeric time format Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Example of retrieving quarterly unemployment data by sex and age, with the time dimension formatted as numeric. ```r dat <- get_ilostat(id = 'UNE_TUNE_SEX_AGE_NB_Q', time_format = 'num', quiet = TRUE) ``` -------------------------------- ### Plotting data with Rilostat Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Example code for plotting data, potentially related to youth unemployment rates. ```r projection = list(type = 'natural earth'), showcountries = TRUE, resolution = 110) # or 50 ) ``` -------------------------------- ### Mapping Youth Unemployment Rate Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html This example demonstrates how to create an interactive map showing the youth unemployment rate across the world for a specific year using Rilostat and plotly. ```r require(Rilostat) if(!require(plotly)){install.packages('plotly')} if(!require(dplyr)){install.packages('dplyr')} if(!require(stringr)){install.packages('stringr')} dat <- get_ilostat(id = 'UNE_DEAP_SEX_AGE_RT_A', filters = list( time = '2019', sex = 'SEX_T', classif1 = '_Y15-24' ), quiet = TRUE) %>% distinct(ref_area, obs_value) %>% left_join( Rilostat:::ilostat_ref_area_mapping %>% select(ref_area, ref_area_plotly)%>% label_ilostat(code = 'ref_area'), by = "ref_area") %>% filter(!obs_value %in% NA) dat %>% plot_geo( z = ~obs_value, text = ~ref_area.label, locations = ~ref_area_plotly ) %>% add_trace( colors = 'Blues', marker = list( line = list( color = toRGB("grey"), width = 0.5) ), showscale = TRUE ) %>% colorbar( title = '%', len = 0.5 ) %>% layout( geo = list( showframe = FALSE, showcoastlines = TRUE, ``` -------------------------------- ### Install Development Version Source: https://ilostat.github.io/Rilostat/index.html Commands to install the development version of the Rilostat package using devtools. ```R if(!require(devtools)){install.packages('devtools')} install_github("ilostat/Rilostat") ``` -------------------------------- ### Install Rilostat Source: https://ilostat.github.io/Rilostat/index.html Command to install the Rilostat package from CRAN. ```R install.packages("Rilostat") ``` -------------------------------- ### Filtering data for youth female unemployment Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Example of filtering data to retrieve youth female unemployment rates for specific countries. ```r # options(ilostat_cache_dir = 'C:/temp') dat <- get_ilostat(id = 'UNE_DEAP_SEX_AGE_RT_A', filters = list( ref_area = c('BRA', 'ZAF'), sex = 'F', classif1 = '_YGE15'), quiet = TRUE) ``` -------------------------------- ### Filtering data for youth male unemployment Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Example of filtering data to retrieve youth male unemployment rates for specific countries. ```r options(ilostat_cache_dir = 'C:/temp') dat <- get_ilostat(id = 'UNE_DEAP_SEX_AGE_RT_A', filters = list( ref_area = c('BRA', 'ZAF'), sex = 'M', classif1 = '_YGE15'), quiet = TRUE) ``` -------------------------------- ### Plotting Labour Underutilization Indicators Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html This example uses Rilostat to fetch data on unemployment, time-related underemployment, and discouraged job-seekers for selected countries. It then processes the data to show the composition of labor underutilization and visualizes it using a ternary plot. ```r require(Rilostat) if(!require(tidyr)){install.packages('tidyr')} if(!require(dplyr)){install.packages('dplyr')} if(!require(plotrix)){install.packages('plotrix')} if(!require(stringr)){install.packages('stringr')} triangle <- get_ilostat( id = c( "EIP_WDIS_SEX_AGE_NB_A", "UNE_TUNE_SEX_AGE_NB_A", "TRU_TTRU_SEX_AGE_NB_A" ), filters = list( ref_area = c("ZAF", "MNG", "CHL"), source = "BA", sex = "SEX_T", classif1 = "YGE15", time = "2013" ), quiet = TRUE ) %>% distinct(ref_area, indicator, obs_value) %>% label_ilostat() %>% group_by(ref_area.label) %>% mutate(obs_value = obs_value / sum(obs_value)) %>% ungroup() %>% mutate( indicator.label = str_replace( indicator.label, fixed(" by sex and age (thousands)"), "" ) ) %>% pivot_wider( names_from = indicator.label, values_from = obs_value ) par(cex=0.75, mar=c(0,0,0,0)) positions <- plotrix::triax.plot( as.matrix(triangle[, c(2,3,4)]), show.grid = TRUE, main = 'Selected labour underutilization indicators', label.points= FALSE, point.labels = triangle$ref_area.label, col.axis="gray50", col.grid="gray90", pch = 19, cex.axis=1.2, cex.ticks=0.7, col="grey50") ind <- which(triangle$ref_area.label %in% triangle$ref_area.label) df <- data.frame(positions$xypos, geo = triangle$ref_area.label) points(df$x[ind], df$y[ind], cex=2, col="red", pch=19) text(df$x[ind], df$y[ind], df$geo[ind], adj = c(0.5,-1), cex=1.5) ``` -------------------------------- ### Get Table of Contents by Reference Area in Spanish Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Retrieves the table of contents for all available datasets by reference area in ILOSTAT, specifically in Spanish (`lang = 'es'`). ```r toc <- get_ilostat_toc(segment = 'ref_area', lang = 'es', quiet = TRUE) ``` -------------------------------- ### Get Table of Contents by Indicator Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Retrieves the table of contents for all available indicators in ILOSTAT. The `quiet = TRUE` argument suppresses messages. ```r toc <- get_ilostat_toc( quiet = TRUE) ``` -------------------------------- ### Downloading data without returning to R Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Shows how to download and cache datasets using back = FALSE and quiet = TRUE, useful for large downloads. ```r get_ilostat(id = get_ilostat_toc(search = 'SDG'), cache_dir = 'c:/temp', cache_format = 'dta', back = FALSE, quiet = TRUE) ``` -------------------------------- ### Usage of get_ilostat function Source: https://ilostat.github.io/Rilostat/reference/get_ilostat.html Demonstrates the basic usage of the get_ilostat function with its various arguments. ```R get_ilostat( id, segment = getOption("ilostat_segment", "indicator"), type = getOption("ilostat_type", "code"), lang = getOption("ilostat_lang", "en"), time_format = getOption("ilostat_time_format", "raw"), filters = getOption("ilostat_filter", "none"), best_source = getOption("ilostat_best_source", "yes"), fixed = getOption("ilostat_fixed", TRUE), cache = getOption("ilostat_cache", TRUE), cache_update = getOption("ilostat_cache_update", TRUE), cache_dir = getOption("ilostat_cache_dir", NULL), cache_format = getOption("ilostat_cache_format", "rds"), back = getOption("ilostat_back", TRUE), cmd = getOption("ilostat_cmd", "none"), quiet = getOption("ilostat_quiet", TRUE) ) ``` -------------------------------- ### Caching data with custom directory and format Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Demonstrates how to use get_ilostat() to cache data in a specified directory and format (e.g., 'dta'). ```r dat <- get_ilostat(id = 'TRU_TTRU_SEX_AGE_NB_M', cache_dir = 'c:/temp', cache_format = 'dta', quiet = TRUE) ``` -------------------------------- ### Filtering data by reference area and sex Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Illustrates applying filters for reference area and sex to retrieve specific subsets of data, followed by a count aggregation. ```r options(ilostat_cache_dir = 'C:/temp') dat <- get_ilostat(id = 'UNE_DEAP_SEX_AGE_RT_A', filters = list( ref_area = c('BRA', 'ZAF'), sex = 'T', classif1 = '_Y15-24'), quiet = TRUE) dplyr::count(dat, ref_area, sex, classif1) ``` -------------------------------- ### Search Table of Contents by Keyword Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Searches the table of contents for indicators containing the word 'bargaining'. ```r toc <- get_ilostat_toc(search = 'bargaining', quiet = TRUE) ``` -------------------------------- ### Usage of label_ilostat Source: https://ilostat.github.io/Rilostat/reference/label_ilostat.html Demonstrates the basic usage of the label_ilostat function. ```R label_ilostat( x, dic = NULL, code = NULL, lang = getOption("ilostat_lang", "en") ) ``` -------------------------------- ### Usage Source: https://ilostat.github.io/Rilostat/reference/get_ilostat_toc.html The function `get_ilostat_toc` can be used with various arguments to download the table of contents from ilostat. ```R get_ilostat_toc( segment = getOption("ilostat_segment", "indicator"), lang = getOption("ilostat_lang", "en"), search = getOption("ilostat_search", "none"), filters = getOption("ilostat_filter", "none"), fixed = getOption("ilostat_fixed", TRUE), cache_dir = getOption("ilostat_cache_dir", NULL), cache_update = getOption("ilostat_cache_update", TRUE), quiet = getOption("ilostat_quiet", TRUE) ) ``` -------------------------------- ### Cleaning the cache Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html A simple function call to remove cached data files. ```r clean_ilostat_cache() ``` -------------------------------- ### Filter Table of Contents for Monthly Data Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Filters the table of contents to include only monthly data ('M') from the Short Term Indicators dataset. ```r toc <- dplyr::filter(get_ilostat_toc(), freq == 'M', quiet = TRUE) ``` -------------------------------- ### Rilostat Distribution Function Usage Source: https://ilostat.github.io/Rilostat/reference/distribution_ilostat.html This snippet shows the usage of the distribution_ilostat function, including its arguments and return value. ```r distribution_ilostat( x, var, .keep = FALSE, quiet = getOption("ilostat_quiet", TRUE) ) ``` -------------------------------- ### Usage Source: https://ilostat.github.io/Rilostat/reference/get_ilostat_dic.html The usage of the get_ilostat_dic function. ```R get_ilostat_dic( dic, lang = getOption("ilostat_lang", "en"), cache_dir = getOption("ilostat_cache_dir", NULL), quiet = getOption("ilostat_quiet", TRUE) ) ``` -------------------------------- ### Search Table of Contents by Multiple Criteria Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html Searches for datasets by reference area that are either 'France' or 'Albania' and are 'Annual'. `fixed = FALSE` allows for pattern matching. ```r toc <- get_ilostat_toc(segment = 'ref_area', search = c('France|Albania', 'Annual'), fixed = FALSE, quiet = TRUE) ``` -------------------------------- ### Usage Source: https://ilostat.github.io/Rilostat/reference/clean_ilostat_cache.html Deletes all cache files from the your ilostat cache directory. ```R clean_ilostat_cache( cache_dir = getOption("ilostat_cache_dir", file.path(tempdir(), "ilostat")), cache_update = getOption("ilostat_cache_update", FALSE), quiet = getOption("ilostat_quiet", TRUE) ) ``` -------------------------------- ### Citation in BibTeX format Source: https://ilostat.github.io/Rilostat/authors.html The citation for the Rilostat package in BibTeX format, suitable for academic papers. ```bibtex @Manual{ title = {Rilostat: Access and Manipulation of ILOSTAT Labour Statistics}, author = {David Bescond}, year = {2026}, note = {R package version 2.5.0}, url = {https://ilostat.github.io/Rilostat/}, } ``` -------------------------------- ### Employment Distribution by Economic Class Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html This code snippet plots the distribution of employed persons by economic class, broken down by sex and age group in South Africa for 2019. It uses ggplot2 and dplyr to create a stacked bar chart. ```r require(Rilostat) if(!require(ggplot2)){install.packages('ggplot2')} if(!require(dplyr)){install.packages('dplyr')} get_ilostat(id = 'EMP_2EMP_SEX_AGE_CLA_NB_A', filters = list( ref_area = 'ZAF', time = '2019', sex = c('M', 'F'), classif1 = c('Y15-24', 'YGE25')), quiet = TRUE) %>% group_by(ref_area, source , indicator , sex , classif1, time) %>% mutate(obs_value = obs_value / max(obs_value) * 100) %>% ungroup % filter(!classif2 %in% c('CLA_ECOCLA_TOTAL', 'CLA_ECOCLA_USDGE3')) % distinct(obs_value, sex, classif1, classif2) % label_ilostat() % ggplot(aes(y=obs_value, x=as.factor(classif1.label), fill=classif2.label)) + geom_bar(stat="identity") + facet_wrap(~as.factor(sex.label)) + coord_flip() + theme(legend.position="top") + ggtitle("Employment by economic class, sex and age, South Africa, 2019") + labs(x="Age group", y="Distribution of economic class (%)", fill="Economic class : ") + theme(plot.title = element_text(hjust = 0.5)) + scale_fill_brewer(type = "div") ``` -------------------------------- ### Male Labour Force Participation Rate Comparison Source: https://ilostat.github.io/Rilostat/articles/Rilostat.html This code snippet visualizes the male labour force participation rate in Germany, France, and the United States from 2005 to 2019 using ggplot2 and dplyr. ```r require(Rilostat) require(ggplot2, quiet = TRUE) require(dplyr, quiet = TRUE) get_ilostat(id = 'EAP_DWAP_SEX_AGE_RT_A', time_format = 'num', filters = list( ref_area = c('FRA', 'USA', 'DEU'), sex = 'SEX_M', classif1 = '_YGE15', timefrom = 2005, timeto = 2019), quiet = TRUE) %>% distinct(ref_area, time, obs_value) %>% ggplot(aes(x = time, y = obs_value, colour = ref_area)) + geom_line() + ggtitle('Male labour force participation rate in selected countries, 2005-2019') + scale_x_continuous(breaks = seq(2005, 2017, 3)) + labs(x="Year", y="Male LFPR (%)", colour="Country:") + theme(legend.position = "top", plot.title = element_text(hjust = 0.5)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.