csodata quick start guide"

  collapse = TRUE,
  comment = "#>"


This guide provides a basic overview of the use of the csodata package for new users. Install (if necessary) and load the package:

# # Install or update the package:
# install.packages("csodata")


Table of Contents

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()

Downloading Data

To download a dataset, use cso_get_data.

tbl1 <- cso_get_data("PEA19")

Metadata can be also downloaded or displayed to console:

meta1 <- cso_get_meta("CDP06")

Geographic Data

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.

shp <- cso_get_geo("NUTS3_2011")

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")

t <- tm_shape(shp) +
                    palette = viridisLite::viridis(20),
                    style="cont", legend.reverse = TRUE,
                    title = "Population 2011") +
       tm_borders(col = "black") +
       tm_layout(frame = FALSE, scale = 1.3)

The data which has been cached locally can be manually cleared once we are done with it.


Try the csodata package in your browser

Any scripts or data that you put into this service are public.

csodata documentation built on Dec. 11, 2021, 9:13 a.m.