knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(opendatascot)
Use opendatascot to download data from statistics.gov.scot with a single line of R code. opendatascot removes the need to write SPARQL code; you simply need the URI of a dataset. opendatascot can be used interactively, or as part of a reproducible analytical pipeline.
You can download an entire dataset, or filter by date and/or geography. We recommend filtering large datasets. If you require a full download of a large dataset, you may need to contact statistics.gov.scot.
You will always need the last part of the URI for your dataset. Find this on the statistics.gov.scot web page for your dataset (in the API tab). For example, the full URI for Average Household Size is Average Household Size:
http://statistics.gov.scot/data/average-household-size
you just need the last part:
average-household-size
Once you have the last part of the URI, set this as the dataset
parameter for ods_dataset()
:
household_size <- ods_dataset(dataset = "average-household-size") head(household_size)
Filtering is useful for large data sets. The filtering parameters for ods_dataset()
are:
geography
Specify a single geography type:
household_size_la <- ods_dataset(dataset = "average-household-size", geography = "la") head(household_size_la)
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.