Nothing
#' Obtenir le dictionnaire des variables / Get the variable dictionary
#'
#' @param year L'annee du recensement (ex: 2023) / Census year (e.g., 2023)
#' @return A data.frame containing the variable dictionary (variable codes, labels, and descriptions) for the given census year.
#' @export
#' @examples
#' get_dictionary(2023)
get_dictionary <- function(year) {
filename <- sprintf("dict_%s.json", year)
dict_path <- system.file("extdata", filename, package = "sencensus")
if (dict_path == "") {
stop(sprintf("Dictionnaire introuvable pour l'annee %s", year))
}
jsonlite::fromJSON(dict_path, simplifyDataFrame = TRUE)
}
#' Chercher des variables dans le dictionnaire / Search variables in dictionary
#'
#' @param keyword Mot-cle a chercher / Search keyword
#' @param year L'annee du recensement (par defaut 2023) / Census year (default 2023)
#' @return A data.frame containing the matching variable dictionary rows.
#' @export
#' @examples
#' search_variables("ethnie", 2023)
search_variables <- function(keyword, year = 2023) {
df <- get_dictionary(year)
# Recherche insensible a la casse
matches <- df[grepl(keyword, df$description, ignore.case = TRUE), ]
return(matches)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.