Skip to content
Permalink
Browse files

updating vignette

  • Loading branch information...
edwindj committed Apr 17, 2018
1 parent 47905aa commit 0ee1b69799131e8da3654e4f410ad2534142c107
Showing with 110 additions and 37 deletions.
  1. +1 −0 .Rbuildignore
  2. +71 −0 README.Rmd
  3. +31 −30 README.md
  4. +7 −7 vignettes/{cbsodata.Rmd → cbsodataR.Rmd}
@@ -4,3 +4,4 @@
^appveyor\.yml$
TODO.md
^docs$
^README\.
@@ -0,0 +1,71 @@
---
output: rmarkdown::github_document
---

```{r, include=FALSE}
library(dplyr)
```


# Statistics Netherlands (www.cbs.nl) opendata API client for R

[![version](http://www.r-pkg.org/badges/version/cbsodataR)](https://CRAN.R-project.org/package=cbsodataR)
![downloads](http://cranlogs.r-pkg.org/badges/cbsodataR)
[![Travis-CI Build Status](https://travis-ci.org/edwindj/cbsodataR.png?branch=master)](https://travis-ci.org/edwindj/cbsodataR)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/edwindj/cbsodatar?branch=master)](https://ci.appveyor.com/project/edwindj/cbsodatar)


Retrieve data from the [open data interface](http://www.cbs.nl/nl-NL/menu/cijfers/statline/open-data/default.htm) (dutch) of Statistics Netherlands (cbs.nl) with *R*.

Python user? Use [cbsodata](https://github.com/J535D165/cbsodata).

## API change

** Version 0.3 has changed the api of the funtions. Old functions (should) still work, but generate warnings to switch to the new api. **

# Installation

From CRAN
```S
install.packages("cbsodataR")
```

The latest development version of `cbsodata` can installed using `devtools`.

```R
devtools::install_github("edwindj/cbsodataR")
```

# Usage

Retrieve list a tables.

```{r}
toc <- cbs_get_toc("Language" = "en")
head(toc)
```

Use the `Identifier` from tables to retrieve table information

```{r}
cbs_get_meta('71509ENG')
```
Or download data.

```{r}
library(dplyr) # just for example's sake
apples <- cbs_get_data("71509ENG")
apples %>%
select(1:4)
```

add label columns:

```{r}
apples %>%
cbs_add_label_columns() %>%
select(1:4)
```

For more information, see `vignette("")
@@ -1,41 +1,45 @@
# Statistics Netherlands (www.cbs.nl) opendata API client for R

**the url of the CBS Open Data api will change from "http" to "https"**
Statistics Netherlands (www.cbs.nl) opendata API client for R
=============================================================

**`cbsodataR` version 2.4 and later will use `https` by default.**
[![version](http://www.r-pkg.org/badges/version/cbsodataR)](https://CRAN.R-project.org/package=cbsodataR) ![downloads](http://cranlogs.r-pkg.org/badges/cbsodataR) [![Travis-CI Build Status](https://travis-ci.org/edwindj/cbsodataR.png?branch=master)](https://travis-ci.org/edwindj/cbsodataR) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/edwindj/cbsodatar?branch=master)](https://ci.appveyor.com/project/edwindj/cbsodatar)

[![version](http://www.r-pkg.org/badges/version/cbsodataR)](https://CRAN.R-project.org/package=cbsodataR)
![downloads](http://cranlogs.r-pkg.org/badges/cbsodataR)
[![Travis-CI Build Status](https://travis-ci.org/edwindj/cbsodataR.png?branch=master)](https://travis-ci.org/edwindj/cbsodataR)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/edwindj/cbsodatar?branch=master)](https://ci.appveyor.com/project/edwindj/cbsodatar)
Retrieve data from the [open data interface](http://www.cbs.nl/nl-NL/menu/cijfers/statline/open-data/default.htm) (dutch) of Statistics Netherlands (cbs.nl) with *R*.

Retrieve data from the [open data interface](http://www.cbs.nl/nl-NL/menu/cijfers/statline/open-data/default.htm) (dutch) of Statistics Netherlands (cbs.nl) with *R*.
Python user? Use [cbsodata](https://github.com/J535D165/cbsodata).

Python user? Use [cbsodata](https://github.com/J535D165/cbsodata).
API change
----------

# Installation
\*\* Version 0.3 has changed the api of the funtions. Old functions (should) still work, but generate warnings to switch to the new api. \*\*

Installation
============

From CRAN
```S

``` s
install.packages("cbsodataR")
```
```

The latest development version of `cbsodata` can installed using `devtools`.

```R
``` r
devtools::install_github("edwindj/cbsodataR")
```

# Usage
Usage
=====

Retrieve list a tables.
```R
> tables <- get_table_list(Language="en")

``` r
> tables <- get_cbs_toc(Language="en")
```

Use the `Identifier` from tables to retrieve table information

```R
``` r
> get_meta('71509ENG')
71509ENG: 'Yield apples and pears', 2013
@@ -45,18 +49,15 @@ Use the `Identifier` from tables to retrieve table information

Or download data

```
> library(dplyr) # to help select data and use the %>% operator
> get_data('71509ENG') %>% select(2:5) %>% head
Source: local data frame [6 x 4]
> library(dplyr) # to help select data and use the %>% operator
> get_data('71509ENG') %>% select(2:5) %>% head
FruitFarmingRegions Periods TotalAppleVarieties_1 CoxSOrangePippin_2
1 Total Netherlands 1997 420 43
2 Total Netherlands 1998 518 40
3 Total Netherlands 1999 568 39
4 Total Netherlands 2000 461 27
5 Total Netherlands 2001 408 30
6 Total Netherlands 2002 354 17
Source: local data frame [6 x 4]

```
FruitFarmingRegions Periods TotalAppleVarieties_1 CoxSOrangePippin_2
1 Total Netherlands 1997 420 43
2 Total Netherlands 1998 518 40
3 Total Netherlands 1999 568 39
4 Total Netherlands 2000 461 27
5 Total Netherlands 2001 408 30
6 Total Netherlands 2002 354 17
@@ -6,7 +6,7 @@ output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{cbsodataR, all data of Statistics Netherlands (CBS)}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
%\VignetteEncoding{UTF-8}
---

```{r, include=FALSE}
@@ -20,15 +20,15 @@ For long SN has put its data on the web in its online database
Since 2014 this data base has an open data web API based on the OData protocol.
The *cbsodataR* package allows for retrieving data right into R.

## Table information
## Table of Contents

A list of tables can be retrieved using the `cbs_get_toc` function.

```{r cbs_get_toc, message=FALSE}
library(dplyr) # not needed, but used in examples below
library(cbsodataR)
toc <- cbs_get_toc(Language="en") # retrieve only enlgish tables
toc <- cbs_get_toc(Language="en") # retrieve only english tables
toc %>%
select(Identifier, ShortTitle)
@@ -37,13 +37,13 @@ toc %>%
Using an "Identifier" from `cbs_get_toc` information on the table can be retrieved with `cbs_get_meta`

```{r get_meta, message=FALSE}
m <- cbs_get_meta('71509ENG')
m
apples <- cbs_get_meta('71509ENG')
apples
```
The meta object contains all metadata properties of cbsodata (see the [original documentation](http://www.cbs.nl/NR/rdonlyres/2561A2B7-CE51-47B9-A838-9968EF67FFB0/0/2014handleidingcbsopendataservices.pdf)) in the form of data.frames. Each data.frame describes properties of the SN table.

```{r, meta2}
names(m)
names(apples)
```

## Data download
@@ -78,5 +78,5 @@ It is possible restrict the download using filter statements. This may shorten t

# Download data

Data can also be donwloaded explicitly by using `cbs_donwload_table`
Data can also be donwloaded explicitly by using `cbs_download_table`

0 comments on commit 0ee1b69

Please sign in to comment.
You can’t perform that action at this time.