README.md

odataR_old

NB this package (based on XML) is replaced by odataR based on JSON.

This package gives access to information made available with the OData interface. It is tested on the information from Statistics Netherlands and therefore the root has as default the value http://opendata.cbs.nl . Another root can be set with the function odataR_set_root . The most important function is odataR_get_table that downloads for a given table_id the main table and uses its subtables to decode dimensions (as Region and Periods). Another important function is odataR_list_tables that gives an overview of the available tables in data.frame format.

Examples ordered by increasing complexity:

1 df = odataR_get_table(table_id="82935NED") Convert table 82935NED to a data.frame with the (two) dimensions (RegioS and Perioden) decoded

2 df = odataR_get_table(table_id="82935NED",keepcode = "RegioS") Same as example1 but the coded version of RegioS is also included

3 df = odataR_get_table(table_id="82935NED",keepcode = c("RegioS","Perioden")) Same as example1 but the coded version of both RegioS and Perioden are included

4 df = odataR_get_table(table_id="82935NED",keepcode = "RegioS", query = "?$filter=startswith(RegioS,'NL01')" ) Same as example2 but the OData server will only return rows where the value of RegioS starts with NL01

5 df = odataR_get_table(table_id="82935NED", query = paste0("?$filter=startswith(RegioS,'NL01')", "&$select=RegioS,Perioden,TotaleInvesteringen_1") ) Same as example4 but the OData server will only return the indicated fields (columns)

6 df = odataR_get_table(table_id="82935NED", query = paste0("?$filter=startswith(RegioS,'NL01')", "&$select=RegioS,Perioden,TotaleInvesteringen_1", "&$skip=2&$top=3") ) Same as example5 but the OData server will only return the third, fourth and fifth row

Description of the query language

The $filter, $select, $skip and $top commands used in the examples 4 and further are elements of the query language for OData described in the OData protocol v4 for version 4 and the OData protocol v3 for version 3. The website of Statistics Netherlands uses version 3.

Additional information about odataR

The folder private contains two PDFs with extra information:

Install odataR

install.packages("devtools") library(devtools) install_github("HanOostdijk/odataR")

References

See also

To my knowledge two other packages concerning OData exist:



HanOostdijk/odataR_old documentation built on May 28, 2019, 8:21 a.m.