combine_cbs_muni: Combine municipalities data frames from different sheets

View source: R/combine_cbs_muni.R

combine_cbs_muniR Documentation

Combine municipalities data frames from different sheets

Description

This function is a wrapper around read_cbs_muni() to help in combining data for cities, local councils and regional councils. From 2015 and earlier, the Israeli CBS publishes municipal data on different sheets and formats for cities and local councils, and for regional councils. This function enables the user to combine the two data frames for selected columns. It is up to the user to take care of the specific match between specific columns.

Usage

combine_cbs_muni(
  path,
  year,
  cols_city,
  cols_rc,
  data_domain = c("physical", "budget"),
  col_names = NULL,
  col_names_from = c("city_lc", "rc")
)

Arguments

path

A character vector of length 1, denoting the local file path to the municipal data file. A full list of available files by the CBS is at the relevant CBS page.

year

A numeric vector of length 1 denoting which year the data file pointed in path is for. Currently supporting 2003-2015, since before 2003 the data structure is very different, and after 2015 the file is already combined.

cols_city

<tidy-select> Columns to keep from the cities and local councils sheet.

cols_rc

<tidy-select> Columns to keep from the regional councils sheet. Should be in the same order of desired columns as in cols_city, since the columns are matched by order.

data_domain

A character vector of length 1, one of c("physical", "budget"). Every Excel municipal data file has a few different data domains, most notably physical and population data, and budget data.

col_names

A character vector containing the new column names of the output tibble. If NULL then the tibble uses the original column names. Must be the same length as the number of columns picked in cols. If not NULL, overrides the choice in col_names_from.

col_names_from

A character vector of length 1, one of c("city_lc", "rc"). Denotes which column names should be kept - those from the cities and local councils sheet, or those from the regional councils sheet.

Value

A tibble with municipal data for a specific year, with the columns from cols_city and cols_rc bound by rows and matched by order of columns. Every row is a municipality and every column is a different variable for this municipality in that year. Be advised all columns are of type character, so you need to parse the data types yourself at will. Column names are merged from the relevant headers, and only single whitespaces are kept. Rows with more than 90% empty cells (usually rows with non-data notes) are removed.

Examples

df_1 <- combine_cbs_muni(
  system.file("extdata", "2009.xls", package = "il.cbs.muni"),
  year = 2009,
  cols_city = c(1:7, 11),
  cols_rc = c(1:7, 25)
)

df_1 |>
  dplyr::glimpse()

df_2 <- combine_cbs_muni(
  system.file("extdata", "2009.xls", package = "il.cbs.muni"),
  year = 2009,
  cols_city = c(1:12),
  cols_rc = c(1:12),
  data_domain = "budget",
  col_names_from = "rc"
)

df_2 |>
  dplyr::glimpse()

il.cbs.muni documentation built on Feb. 13, 2026, 1:06 a.m.