loadCantonsCHportraits: Swiss cantonal indicators

View source: R/cantonal_ch_indicators.R

loadCantonsCHportraitsR Documentation

Swiss cantonal indicators

Description

Load socio-demographic data by the Swiss Statistical Office.

Usage

loadCantonsCHportraits(file = "cantonal_CH_2020_indicators_je-f-21.03.02.csv")

Arguments

file

the name of the csv file to load (output by processPortraitsRegionauxCantons) or the raw excel file name from the Swiss Statistical office with indicators by canton to be processed by the aforementionned function

Details

Run processPortraitsRegionauxCantons() to generate a readable csv file for loadCantonsCHportraits

Value

a data.frame

Examples

cantonalI <- loadCantonsCHportraits()
## Not run: 
require(geofacet)
## plot with geofacet the share the highest education reached by canton

# wrangle data
edu <- cantonalI %>% 
  select(`Sans formation postobligatoire (dès 25 ans)`, 
  `Degré secondaire II (dès 25 ans)`, 
  `Degré tertiaire (dès 25 ans)`) %>% 
  rownames_to_column()
stopifnot(all(rowSums(edu %>% select(-rowname)) %>% round() == 100))
colnames(edu) <- gsub(" \\(dès 25 ans\\)", "", colnames(edu))
edu <- edu %>% gather(education, pourc, -rowname) %>% 
  rename(code = rowname) %>% 
  mutate(education = fct_inorder(education))
  
# Plot
ggplot(edu) + 
geom_col(aes(x = education, y = pourc, fill = education)) + 
coord_flip() +
facet_geo( ~ code, grid = ch_cantons_grid2, label = "name_fr") +
scale_x_discrete(labels = NULL, name ="") +
scale_y_continuous(name = "") +
theme(legend.position = "top") +
ggtitle("Niveau d'éducation atteint par canton")
    

## End(Not run)

d-qn/taMap documentation built on Oct. 25, 2023, 8:43 a.m.