@@ -23,7 +23,7 @@ datasets |>
23
23
select(Identifier , ShortTitle )
24
24
```
25
25
26
- ## # A tibble: 962 × 2
26
+ ## # A tibble: 1,005 × 2
27
27
## Identifier ShortTitle
28
28
## <chr> <chr>
29
29
## 1 80783eng Agriculture; general farm type, region
@@ -36,7 +36,7 @@ datasets |>
36
36
## 8 84312ENG Caribbean NL; students MBO
37
37
## 9 84732ENG Caribbean NL; pupils and students
38
38
## 10 81154eng Caribbean NL; electricity and water
39
- ## # ℹ 952 more rows
39
+ ## # ℹ 995 more rows
40
40
41
41
## Search for tables
42
42
@@ -50,7 +50,7 @@ toc_apples[, c("Identifier", "ShortTitle", "score")]
50
50
## # A tibble: 1 × 3
51
51
## Identifier ShortTitle score
52
52
## <chr> <chr> <dbl>
53
- ## 1 71509ENG Yield apples and pears, 1997 - 2017 2.62
53
+ ## 1 71509ENG Yield apples and pears, 1997 - 2017 2.64
54
54
55
55
## Other catalogs
56
56
@@ -61,7 +61,8 @@ catalogs <- cbs_get_catalogs()
61
61
catalogs $ Identifier
62
62
```
63
63
64
- ## [1] "CBS" "MKB" "IV3" "MLZ" "JM" "RIVM" "Politie" "MVstat" "AZW" "InterReg" "SXstat"
64
+ ## [1] "CBS" "MKB" "IV3" "MLZ" "JM" "RIVM"
65
+ ## [7] "Politie" "MVstat" "AZW" "InterReg" "SXstat"
65
66
66
67
## Metadata
67
68
@@ -101,7 +102,8 @@ SN table.
101
102
names(apples )
102
103
```
103
104
104
- ## [1] "TableInfos" "DataProperties" "CategoryGroups" "FruitFarmingRegions" "Periods"
105
+ ## [1] "TableInfos" "DataProperties" "CategoryGroups"
106
+ ## [4] "FruitFarmingRegions" "Periods"
105
107
106
108
## Data download
107
109
@@ -114,8 +116,6 @@ cbs_get_data('71509ENG') |>
114
116
head()
115
117
```
116
118
117
- ## | | | 0% | |====================================================================================================================================| 100%
118
-
119
119
## # A tibble: 6 × 4
120
120
## FruitFarmingRegions Periods TotalAppleVarieties_1 CoxSOrangePippin_2
121
121
## <chr> <chr> <int> <int>
@@ -144,8 +144,6 @@ cbs_get_data_from_link("https://opendata.cbs.nl/dataportaal/#/CBS/en/dataset/715
144
144
## Executing:
145
145
## cbs_get_data(id = "71509ENG", select = c("FruitFarmingRegions", "Periods", "TotalAppleVarieties_1", "CoxSOrangePippin_2", "DelbarestivaleDelcorf_3", "Elstar_4", "GoldenDelicious_5", "Jonagold_6", "Jonagored_7", "Junami_8", "Kanzi_9", "RodeBoskoopRennetApple_10", "Rubens_11", "OtherAppleVarieties_12", "TotalAppleVarieties_20", "CoxSOrangePippin_21", "DelbarestivaleDelcorf_22", "Elstar_23", "GoldenDelicious_24", "Jonagold_25", "Jonagored_26", "Junami_27", "Kanzi_28", "RodeBoskoopRennetApple_29", "Rubens_30", "OtherAppleVarieties_31"), FruitFarmingRegions = c("1", "2", "3", "4", "5"), Periods = c("1997JJ00", "2012JJ00", "2013JJ00", "2016JJ00"), deeplink = "https://opendata.cbs.nl/dataportaal/#/CBS/en/dataset/71509ENG/table?dl=193CB", base_url = "http://opendata.cbs.nl")
146
146
147
- ## | | | 0% | |====================================================================================================================================| 100%
148
-
149
147
## # A tibble: 6 × 4
150
148
## ID FruitFarmingRegions Periods TotalAppleVarieties_1
151
149
## <int> <chr> <chr> <int>
@@ -169,8 +167,6 @@ cbs_get_data('71509ENG') |>
169
167
head()
170
168
```
171
169
172
- ## | | | 0% | |====================================================================================================================================| 100%
173
-
174
170
## # A tibble: 6 × 4
175
171
## FruitFarmingRegions FruitFarmingRegions_label Periods Periods_label
176
172
## <chr> <fct> <chr> <fct>
@@ -181,7 +177,7 @@ cbs_get_data('71509ENG') |>
181
177
## 5 1 Total Netherlands 2001JJ00 2001
182
178
## 6 1 Total Netherlands 2002JJ00 2002
183
179
184
- ### Adding Date column
180
+ ### Adding a Date column
185
181
186
182
The period/time columns of Statistics Netherlands (CBS) contain coded
187
183
time periods: e.g. 2018JJ00 (i.e. 2018), 2018KW03 (i.e. 2018 Q3),
@@ -195,8 +191,6 @@ cbs_get_data('71509ENG') |>
195
191
head()
196
192
```
197
193
198
- ## | | | 0% | |====================================================================================================================================| 100%
199
-
200
194
## # A tibble: 6 × 3
201
195
## Periods Periods_Date Periods_freq
202
196
## <chr> <date> <fct>
@@ -217,8 +211,6 @@ cbs_get_data('71509ENG') |>
217
211
head()
218
212
```
219
213
220
- ## | | | 0% | |====================================================================================================================================| 100%
221
-
222
214
## # A tibble: 6 × 3
223
215
## Periods Periods_numeric Periods_freq
224
216
## <chr> <int> <fct>
@@ -229,6 +221,29 @@ cbs_get_data('71509ENG') |>
229
221
## 5 2001JJ00 2001 Y
230
222
## 6 2002JJ00 2002 Y
231
223
224
+ ### Adding unit columns
225
+
226
+ Each topic in the CBS data can have a unit, e.g. “%” or “mln kg”. Using
227
+ ` cbs_add_unit_column ` for each (specified) topic a unit column will be
228
+ added.
229
+
230
+ ``` r
231
+ cbs_get_data(' 71509ENG' ) | >
232
+ cbs_add_unit_column() | >
233
+ subset(,1 : 4 ) | >
234
+ head()
235
+ ```
236
+
237
+ ## # A tibble: 6 × 4
238
+ ## FruitFarmingRegions Periods TotalAppleVarieties_1 TotalAppleVarieties_1_unit
239
+ ## <chr> <chr> <int> <chr>
240
+ ## 1 1 1997JJ00 420 mln kg
241
+ ## 2 1 1998JJ00 518 mln kg
242
+ ## 3 1 1999JJ00 568 mln kg
243
+ ## 4 1 2000JJ00 461 mln kg
244
+ ## 5 1 2001JJ00 408 mln kg
245
+ ## 6 1 2002JJ00 354 mln kg
246
+
232
247
## Select and filter
233
248
234
249
It is possible restrict the download using filter statements. This may
@@ -248,7 +263,8 @@ apples <- cbs_get_meta('71509ENG')
248
263
names(apples )
249
264
```
250
265
251
- ## [1] "TableInfos" "DataProperties" "CategoryGroups" "FruitFarmingRegions" "Periods"
266
+ ## [1] "TableInfos" "DataProperties" "CategoryGroups"
267
+ ## [4] "FruitFarmingRegions" "Periods"
252
268
253
269
``` r
254
270
# meta data for column Periods
@@ -290,13 +306,12 @@ head(apples$FruitFarmingRegions[,1:2 ])
290
306
cbs_add_label_columns()
291
307
```
292
308
293
- ## | | | 0% | |====================================================================================================================================| 100%
294
-
295
309
## # A tibble: 2 × 5
296
- ## FruitFarmingRegions FruitFarmingRegions_label Periods Periods_label TotalAppleVarieties_1
297
- ## <chr> <fct> <chr> <fct> <int>
298
- ## 1 1 Total Netherlands 2000JJ00 2000 461
299
- ## 2 1 Total Netherlands 2001JJ00 2001 408
310
+ ## FruitFarmingRegions FruitFarmingRegions_label Periods Periods_label
311
+ ## <chr> <fct> <chr> <fct>
312
+ ## 1 1 Total Netherlands 2000JJ00 2000
313
+ ## 2 1 Total Netherlands 2001JJ00 2001
314
+ ## # ℹ 1 more variable: TotalAppleVarieties_1 <int>
300
315
301
316
- To filter for values in a column that have a substring e.g. “JJ” you
302
317
can use ` <column_name> = has_substring(<substring>) ` to ` cbs_get_data `
@@ -314,12 +329,11 @@ head(apples$FruitFarmingRegions[,1:2 ])
314
329
cbs_add_label_columns()
315
330
```
316
331
317
- ## | | | 0% | |====================================================================================================================================| 100%
318
-
319
332
## # A tibble: 1 × 5
320
- ## FruitFarmingRegions FruitFarmingRegions_label Periods Periods_label TotalAppleVarieties_1
321
- ## <chr> <fct> <chr> <fct> <int>
322
- ## 1 1 Total Netherlands 2000JJ00 2000 461
333
+ ## FruitFarmingRegions FruitFarmingRegions_label Periods Periods_label
334
+ ## <chr> <fct> <chr> <fct>
335
+ ## 1 1 Total Netherlands 2000JJ00 2000
336
+ ## # ℹ 1 more variable: TotalAppleVarieties_1 <int>
323
337
324
338
- To combine values and substring use the “\| ” operator:
325
339
` Periods = eq("2020JJ00") | has_substring("KW") `
@@ -336,13 +350,12 @@ head(apples$FruitFarmingRegions[,1:2 ])
336
350
cbs_add_label_columns()
337
351
```
338
352
339
- ## | | | 0% | |====================================================================================================================================| 100%
340
-
341
353
## # A tibble: 2 × 5
342
- ## FruitFarmingRegions FruitFarmingRegions_label Periods Periods_label TotalAppleVarieties_1
343
- ## <chr> <fct> <chr> <fct> <int>
344
- ## 1 1 Total Netherlands 2000JJ00 2000 461
345
- ## 2 1 Total Netherlands 2010JJ00 2010 334
354
+ ## FruitFarmingRegions FruitFarmingRegions_label Periods Periods_label
355
+ ## <chr> <fct> <chr> <fct>
356
+ ## 1 1 Total Netherlands 2000JJ00 2000
357
+ ## 2 1 Total Netherlands 2010JJ00 2010
358
+ ## # ℹ 1 more variable: TotalAppleVarieties_1 <int>
346
359
347
360
# Download data
348
361
0 commit comments