Description Usage Arguments Details Value See Also Examples
Load socio-demographic data by the Swiss Statistical Office.
Process Portraits régionaux de la Suisse commune xls
Load the NPA/PLZ/ Zip code for Switzerland
1 2 3 4 5 6 | loadCommunesCHportraits()
processPortraitsRegionauxCommune(file = "je-f-21.03.01.xls",
output = "communesCH_2016_indicators_je-f-21.03.01.csv")
loadCHzipcode()
|
file |
the raw excel file name from the Swiss Statistical office with indicators by commune |
output |
the output file name to be saved in the package inst/extdata |
Run processPortraitsRegionauxCommune() to generate a readable csv file for loadCommunesCHportraits
The matrix has the commune BFS code as rowname and 3 attributes:
communeName
the text name of the commune (same length as the matrix length)
indicatorYear
& indicatorGroup
respectively the year and the category of the communal indicator (both of same length as the matrix width). See http://www.bfs.admin.ch/bfs/portal/fr/index/regionen/02/key.html
a matrix
a data.frame
Office fédéral de la statistique > Les Régions > Communes > Données et explications (portraits): https://www.bfs.admin.ch/bfs/fr/home/statistiques/statistique-regions/portraits-regionaux-chiffres-cles/communes.assetdetail.328133.html
The cleaning up of raw xls file:
Remove all the empty lines (header has 3 lines: Indicator type, indicator, year)
Reorder the header for: indicator type, year, indicator
Remove in the data table, the line for Switzerland
Remove the text at the bottom
Save as csv
http://opendata.admin.ch/de/dataset/ch-swisstopo-vd-ortschaftenverzeichnis_plz/resource/35001b61-e7c1-4124-89fa-17fac7b1139e from: http://opendata.admin.ch/de/dataset/ch-swisstopo-vd-ortschaftenverzeichnis_plz
http://opendata.admin.ch/de/dataset/ch-swisstopo-vd-ortschaftenverzeichnis_plz/resource/35001b61-e7c1-4124-89fa-17fac7b1139e from: http://opendata.admin.ch/de/dataset/ch-swisstopo-vd-ortschaftenverzeichnis_plz
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | communeData <- loadCommunesCHportraits()
colnames(communeData)
rownames(communeData)
# Select only "surface" indicators
colIdx <- which(attr(communeData, "indicatorGroup") == "Surface")
head(communeData[,colIdx])
zipcode <- loadCHzipcode()
match(zipcode$Gemeindename, attr(communeData, "communeName"))
##' \dontrun{
colnames(data)
g1 <- ggplot(data = as.data.frame(data), aes(x = `Etrangers en %`, y = UDC)) +
geom_point(aes(size = Habitants), alpha = 0.5, colour = swiTheme::swi_col[1])
g1 + swiTheme::swi_theme()
}
## Not run:
processPortraitsRegionauxCommune()
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.