A brief introduction to the r-package PxWebApiData is given below. Three calls to the main function, ApiData, is demonstrated. First, two calls for reading data sets are shown. The last call captures meta data. However, in practise, one may look at the meta data first. At the end, some background is given.
library(knitr) library(PxWebApiData) options(max.print = 50)
The dataset below has three variables, Region, ContentsCode and Tid. The variables can be used as input parameters. Here two of the parameters are specified by variable id's and one parameter is specified by indices. Negative values are used to specify reversed indices. Thus, we here obtain the two first and the two last years in the data.
A list of two data frames is returned; the label version and the id version.
ApiData("http://data.ssb.no/api/v0/en/table/04861", Region = c("0811", "0301"), ContentsCode = "Bosatte", Tid = c(1, 2, -2, -1))
All possible values is obtained by TRUE and corresponds to "all" in the api query. Elimination of a variables is obtained by FALSE. An imaginary value corresponds to "top" in the api query.
ApiData("http://data.ssb.no/api/v0/en/table/04861", Region = FALSE, ContentsCode = TRUE, Tid = 3i)
Meta information about the data set can be obtained by "returnMetaFrames = TRUE".
ApiData("http://data.ssb.no/api/v0/en/table/04861", returnMetaFrames = TRUE)
PxWeb and it's API, PxWebApi is used as output database (Statbank) by many statistical agencies in the Nordic countries and several others, i.e. Statistics Norway, Statistics Finland, Statistics Sweden. See list of installations: https://www.scb.se/en/services/statistical-programs-for-px-files/px-web/pxweb-examples/
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.