Skip to content

Commit

Permalink
feat: add data to nationality and ethnical composition for Switzerlan…
Browse files Browse the repository at this point in the history
…d and Russia
  • Loading branch information
Nenuial committed Sep 24, 2024
1 parent 0bd14d7 commit 37b73d5
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 0 deletions.
15 changes: 15 additions & 0 deletions R/data_doc_oc_russie.R
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,18 @@
#' }
#' @source <https://sreda.org/arena>
"oc_russie_2012_religion"

#' Religion par région
#'
#' Un tableau de la religion par région en 2012.
#'
#' @format Un tibble avec 4 colonnes et 1422 lignes
#' \describe{
#' \item{type_pop}{Population urbaine ou rurale}
#' \item{sexe}{Homme, femme ou les deux}
#' \item{ethnie}{Nom de l'ethnie}
#' \item{ethnie_detail}{Détail concernant de l'ethnie}
#' \item{population}{Population}
#' }
#' @source <https://rosstat.gov.ru/storage/mediabank/Tom5_tab1_VPN-2020.xlsx>
"oc_russie_2020_population_composition"
13 changes: 13 additions & 0 deletions R/data_doc_oc_suisse.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,16 @@
#' }
#' @source <https://www.pxweb.bfs.admin.ch/pxweb/fr/px-x-0103010000_151/-/px-x-0103010000_151.px/>
"oc_suisse_2000_religion"

#' Nationalite en Suisse
#'
#' Un tableau avec le nombre de personnes par nationalité
#' en Suisse en 2023.
#'
#' @format Un tibble avec 2 colonnes et 210 lignes
#' \describe{
#' \item{Nationalite}{La nationalité}
#' \item{Population}{Population (chiffre absolu)}
#' }
#' @source <https://www.pxweb.bfs.admin.ch/pxweb/fr/px-x-0103010000_151/-/px-x-0103010000_151.px/>
"oc_suisse_2023_nationalite"
24 changes: 24 additions & 0 deletions data-raw/oc_russie.R
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,30 @@ cells |>

usethis::use_data(oc_russie_2012_religion, overwrite = TRUE)


# Population composition (ethnicity) -------------------------------------

pop_composition <- here::here("inst/extdata/oc_russie/rosstat/population/2020_population_composition.xlsx")
cells <- tidyxl::xlsx_cells(pop_composition)
formats <- tidyxl::xlsx_formats(pop_composition)

cells |>
dplyr::filter(row > 4 & row < 203) |>
dplyr::filter(sheet == " Fédération de Russie") |>
unpivotr::behead(direction = "up-left", name = "type_pop") |>
unpivotr::behead(direction = "up", name = "sexe") |>
unpivotr::behead(direction = "left", name = "ethnie") |>
dplyr::select(type_pop, sexe, ethnie, population = numeric) |>
tidyr::drop_na(population) |>
dplyr::mutate(ethnie = stringr::str_trim(ethnie)) |>
tidyr::extract(
ethnie,
into = c("ethnie", "ethnie_detail"),
regex = r"{(.*?)\s?\((.*)\)}"
) -> oc_russie_2020_population_composition

usethis::use_data(oc_russie_2020_population_composition, overwrite = TRUE)

# Open documentation file ------------------------------------------------

usethis::edit_file(here::here("R/data_doc_oc_russie.R"))
11 changes: 11 additions & 0 deletions data-raw/oc_suisse.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ readr::read_csv("inst/extdata/oc_suisse/ofs/religion/religion_2000.csv") |>

usethis::use_data(oc_suisse_2000_religion, overwrite = TRUE)


# Nationalité ------------------------------------------------------------

readr::read_csv("inst/extdata/oc_suisse/ofs/population/nationalite.csv") |>
dplyr::rename(Annee = 1) |>
dplyr::rename(Nationalite = 2) |>
dplyr::rename(Population = 3) |>
dplyr::select(-Annee) -> oc_suisse_2023_nationalite

usethis::use_data(oc_suisse_2023_nationalite, overwrite = TRUE)

# Open documentation file ------------------------------------------------

usethis::edit_file(here::here("R/data_doc_oc_suisse.R"))
Binary file added data/oc_russie_2020_population_composition.rda
Binary file not shown.
Binary file added data/oc_suisse_2023_nationalite.rda
Binary file not shown.
26 changes: 26 additions & 0 deletions man/oc_russie_2020_population_composition.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/oc_suisse_2023_nationalite.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 37b73d5

Please sign in to comment.