This guide provides a basic overview of the use of the csodata package for new users. Install (if necessary) and load the package:
A list of all the table available on the cso StatBank can be downloaded with cso_get_toc
. You can search throught the title field using cso_search_toc
. (A “Loaded cached toc” or “Loaded cached data” message indicates that the data was retrieved from the cache, instead of being downloaded again.)
toc <- cso_get_toc()
#> Loaded cached toc
head(toc)
#> LastModified title
#> 1 2020-12-16 00:20:00 2002 Population and Percentage Change 1996 and 2002
#> 2 2020-12-16 00:20:00 1996 Population and Percentage Change 1991 and 1996
#> 3 2020-12-16 00:20:00 1996 Population Aged 15 Years and Over
#> 4 2020-12-16 00:20:00 2002 Population
#> 5 2020-12-16 00:20:00 2002 Population Change since
#> 6 2020-12-16 00:20:00 Population Change and Average Annual Rates
#> id
#> 1 B0101
#> 2 A0101
#> 3 A0502
#> 4 B0103
#> 5 B0401
#> 6 B0402
To download a dataset, use cso_get_data
.
Metadata can be also downloaded or displayed to console:
meta1 <- cso_get_meta("CDP06")
#> Loaded cached data
cso_disp_meta("CDP06")
#> Loaded cached data
#> *** METADATA ***
#> CSO Table = Annual Estimated Net Migration 1951 to 2011 per 1,000 of Average Population
#> Units = Number
#> Copyright = Central Statistics Office, Ireland
#> Time interval in data = Year
#> Are these statistics experimental? -FALSE
#> Date last modified = 2020-10-30T11:00:00.000Z
#> Variables:
#> [1] "Year" "Intercensal Period" "Province or County"
#>
#> Statistics:
#> [1] "Annual Estimated Net Migration 1951 to 2011 per 1,000 of Average Population"
Geographic vector data in ESRI shapefile format can be downloaded for use in mapping. This uses the older 2011 data, which includes demographic information. Newer maps, including the revisions to the NUTS regions made in 2016, is also available.
This data can be plotted using the tmap
package. Here we plot the 2011 population, which is included as the “TOTAL2011” column in the map data.
# install.packages("tmap")
library(tmap)
t <- tm_shape(shp) +
tm_fill(col="TOTAL2011",
palette = viridisLite::viridis(20),
style="cont", legend.reverse = TRUE,
title = "Population 2011") +
tm_borders(col = "black") +
tm_layout(frame = FALSE, scale = 1.3)
t