Title: | Statistics Netherlands (CBS) Open Data API Client v4 |
---|---|
Description: | The data and meta data from Statistics Netherlands (<https://www.cbs.nl>) can be browsed and downloaded. The client uses the OData v4 API of Statistics Netherlands. |
Authors: | Edwin de Jonge [aut, cre] , Han Oostdijk [ctb] |
Maintainer: | Edwin de Jonge <[email protected]> |
License: | GPL-3 |
Version: | 0.9.3.9000 |
Built: | 2024-11-20 03:34:07 UTC |
Source: | https://github.com/statistiekcbs/cbsodata4 |
Add extra date columns to data set, for the creation of time series or graphics.
cbs4_add_date_column(data, date_type = c("Date", "numeric"), ...)
cbs4_add_date_column(data, date_type = c("Date", "numeric"), ...)
data |
|
date_type |
Type of date column: "Date", "numeric". See details. |
... |
future use. |
Time periods in data of CBS are coded: yyyyXXww (e.g. 2018JJ00, 2018MM10, 2018KW02),
which contains year (yyyy), type (XX) and index (ww). cbs4_add_date_column
converts
these codes into a Date()
or numeric
.
"Date"
will create a date that signifies the start of the period:
"2018JJ00" will turn into "2018-01-01"
"2018KW02" will turn into "2018-04-01"
"numeric"
creates a fractional
number which signs the "middle" of the period. e.g. 2018JJ00 -> 2018.5 and
2018KW01 -> 2018.167. This is for the following reasons: otherwise 2018.0 could mean
2018, 2018 Q1 or 2018 Jan, and furthermore 2018.75 is a bit strange for 2018 Q4.
If all codes in the dataset have frequency "Y" the numeric output will be integer
.
The <period_freq>
column indicates the period type / frequency:
Y
: year
Q
: quarter
M
: month
W
: week
D
: day
original dataset with two added columns: <period>_Date
and
<period>_freq
. See details.
Other add metadata columns:
cbs4_add_label_columns()
,
cbs4_add_unit_column()
if (interactive()){ # works on observations... obs <- cbs4_get_observations( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = "NL01" # code for region NL , Measure = "M003371_2" ) # add a Periods_Date column obs_d <- cbs4_add_date_column(obs) obs_d # add a Periods_numeric column obs_d <- cbs4_add_date_column(obs, date_type = "numeric") obs_d # works on data d <- cbs4_get_data( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = "NL01" # code for region NL , Measure = "M003371_2" ) cbs4_add_date_column(d) }
if (interactive()){ # works on observations... obs <- cbs4_get_observations( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = "NL01" # code for region NL , Measure = "M003371_2" ) # add a Periods_Date column obs_d <- cbs4_add_date_column(obs) obs_d # add a Periods_numeric column obs_d <- cbs4_add_date_column(obs, date_type = "numeric") obs_d # works on data d <- cbs4_get_data( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = "NL01" # code for region NL , Measure = "M003371_2" ) cbs4_add_date_column(d) }
Add columns with labels to the dataset.
cbs4_add_label_columns(data, ...)
cbs4_add_label_columns(data, ...)
data |
downloaded with |
... |
not used |
cbs4_add_label_columns()
adds for the Measure
and each <Dimension>
column an extra column MeasureLabel
( <Dimension>Label
) that contains
the Title
of each code, making the table more digestible. Title
and
other metadata can also be found using cbs4_get_metadata()
.
original dataset with extra label columns. See details.
Other add metadata columns:
cbs4_add_date_column()
,
cbs4_add_unit_column()
if (interactive()){ # works on observations obs <- cbs4_get_observations("84287NED", Perioden="2019MM12") obs # without label columns obs_labeled <- cbs4_add_label_columns(obs) obs_labeled # works on data d <- cbs4_get_data("84287NED", Perioden="2019MM12") d # cbs4_get_data automagically labels measure columns. d_labeled <- cbs4_add_label_columns(d) d_labeled }
if (interactive()){ # works on observations obs <- cbs4_get_observations("84287NED", Perioden="2019MM12") obs # without label columns obs_labeled <- cbs4_add_label_columns(obs) obs_labeled # works on data d <- cbs4_get_data("84287NED", Perioden="2019MM12") d # cbs4_get_data automagically labels measure columns. d_labeled <- cbs4_add_label_columns(d) d_labeled }
Add a unit column the unit of each measure.
cbs4_add_unit_column(data, ...)
cbs4_add_unit_column(data, ...)
data |
downloaded with |
... |
not used |
cbs4_add_unit_column()
retrieves the Unit
s for each Measure from
MeasureCodes
in the metadata (cbs4_get_metadata()
) and adds this to the
observations data set.
original observations data.frame()
with extra Unit
column.
Other add metadata columns:
cbs4_add_date_column()
,
cbs4_add_label_columns()
if (interactive()){ # works only on observations obs <- cbs4_get_observations("84287NED", Perioden="2019MM12") obs # without Unit column obs_unit <- cbs4_add_unit_column(obs) obs_unit # with unit column }
if (interactive()){ # works only on observations obs <- cbs4_get_observations("84287NED", Perioden="2019MM12") obs # without Unit column obs_unit <- cbs4_add_unit_column(obs) obs_unit # with unit column }
Download observations and metadata to a directory. This function is the working
horse for cbs4_get_data()
and cbs4_get_observations()
and has many of the same
options. This function is useful if you do not want to load an entire dataset
into memory, but just download the data and metadata in csv format.
cbs4_download( id, download_dir = id, ..., query = NULL, catalog = "CBS", show_progress = interactive() && !verbose, sep = ",", verbose = getOption("cbsodata4.verbose", FALSE), base_url = getOption("cbsodata4.base_url", BASEURL4) )
cbs4_download( id, download_dir = id, ..., query = NULL, catalog = "CBS", show_progress = interactive() && !verbose, sep = ",", verbose = getOption("cbsodata4.verbose", FALSE), base_url = getOption("cbsodata4.base_url", BASEURL4) )
id |
Identifier of publication |
download_dir |
directory where files are to be stored |
... |
optional selection statement to retrieve a subset of the data. |
query |
optional odata4 query in odata syntax (overwrites any specification in |
catalog |
Catalog to download from |
show_progress |
|
sep |
seperator to be used in writing the data |
verbose |
Should messages be printed... |
base_url |
Possible other website which implements same protocol. |
metadata of table (invisible()
).
Other data-download:
cbs4_get_data()
,
cbs4_get_observations()
Retrieve catalogs of Statistics Netherlands. Beside the main "CBS" catalog other catalogs contain extra datasets that are not part of the main production of CBS / Statistics Netherlands.
cbs4_get_catalogs( base_url = getOption("cbsodata4.base_url", BASEURL4), verbose = getOption("cbsodata4.verbose", FALSE) )
cbs4_get_catalogs( base_url = getOption("cbsodata4.base_url", BASEURL4), verbose = getOption("cbsodata4.verbose", FALSE) )
base_url |
possible other url that implements same interface |
verbose |
if |
data.frame()
with the different catalogs available.
Other datasets:
cbs4_get_datasets()
Get data from table id
. The data of a CBS opendata table is in so-called wide
format. Each Measure
has its own column.
cbs4_get_data( id, catalog = "CBS", ..., query = NULL, name_measure_columns = TRUE, show_progress = interactive() && !verbose, download_dir = file.path(tempdir(), id), verbose = getOption("cbsodata4.verbose", FALSE), sep = ",", as.data.table = FALSE, base_url = getOption("cbsodata4.base_url", BASEURL4) )
cbs4_get_data( id, catalog = "CBS", ..., query = NULL, name_measure_columns = TRUE, show_progress = interactive() && !verbose, download_dir = file.path(tempdir(), id), verbose = getOption("cbsodata4.verbose", FALSE), sep = ",", as.data.table = FALSE, base_url = getOption("cbsodata4.base_url", BASEURL4) )
id |
Identifier of the Opendata table. Can be retrieved with |
catalog |
Catalog in which the dataset is to be found. |
... |
optional selections on data, passed through to cbs4_download. See examples |
query |
optional query in odata4 syntax (overwrites any specification in |
name_measure_columns |
|
show_progress |
if |
download_dir |
directory in which the data and metadata is downloaded. By default this is temporary directory, but can be set manually |
verbose |
if |
sep |
separator to be used to download the data. |
as.data.table |
|
base_url |
Possible other url which implements same protocol. |
The returned data.frame()
has the following columns:
For each dimension a separate column with category identifiers. Category
labels can be added with cbs4_add_label_columns()
or found in cbs4_get_metadata()
.
Date columns can be added with cbs4_add_date_column()
.
For each Measure / Topic a separate column with values. Units can be found in
cbs4_get_metadata()
(MeasureCodes
).
For a long format instead of wide format see cbs4_get_observations()
which has one Measure
column and a Value
column.
a data.frame()
or data.table()
object. See details.
Other data-download:
cbs4_download()
,
cbs4_get_observations()
if (interactive()){ # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 ) # filter on multiple Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = c("2019MM12", "2020MM01") # december 2019, january 2020 ) # to filter on a dimension just add the filter to the query # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains cbs4_get_data("84287NED" , Perioden = contains("2020") , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with multiple contains cbs4_get_data("84287NED" , Perioden = contains(c("2019MM1", "2020")) , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains or = "2019MM12 cbs4_get_data("84287NED" , Perioden = contains("2020") | "2019MM12" , BedrijfstakkenBranchesSBI2008 = "T001081" ) # This all works on observations too cbs4_get_observations( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = contains("PV") # provinces , Measure = "M003371_2" # topic selection ) # supply your own odata 4 query cbs4_get_data("84287NED", query = "$filter=Perioden eq '2019MM12'") # an odata 4 query will overrule other filter statements cbs4_get_data("84287NED" , Perioden = "2018MM12" , query = "$filter=Perioden eq '2019MM12'" ) # With query argument an odata4 expression with other (filter) functions can be used cbs4_get_observations( id = "80784ned" # table id ,query = paste0( # odata4 query "$skip=4", # skip the first 4 rows of the filtered result "&$top=20", # then slice the first 20 rows of the filtered result "&$select=Measure,Geslacht,Perioden,RegioS,Value", # omit the Id and ValueAttribute fields "&$filter=endswith(Measure,'_1')") # filter only Measure ending on '_1' ) }
if (interactive()){ # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 ) # filter on multiple Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = c("2019MM12", "2020MM01") # december 2019, january 2020 ) # to filter on a dimension just add the filter to the query # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains cbs4_get_data("84287NED" , Perioden = contains("2020") , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with multiple contains cbs4_get_data("84287NED" , Perioden = contains(c("2019MM1", "2020")) , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains or = "2019MM12 cbs4_get_data("84287NED" , Perioden = contains("2020") | "2019MM12" , BedrijfstakkenBranchesSBI2008 = "T001081" ) # This all works on observations too cbs4_get_observations( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = contains("PV") # provinces , Measure = "M003371_2" # topic selection ) # supply your own odata 4 query cbs4_get_data("84287NED", query = "$filter=Perioden eq '2019MM12'") # an odata 4 query will overrule other filter statements cbs4_get_data("84287NED" , Perioden = "2018MM12" , query = "$filter=Perioden eq '2019MM12'" ) # With query argument an odata4 expression with other (filter) functions can be used cbs4_get_observations( id = "80784ned" # table id ,query = paste0( # odata4 query "$skip=4", # skip the first 4 rows of the filtered result "&$top=20", # then slice the first 20 rows of the filtered result "&$select=Measure,Geslacht,Perioden,RegioS,Value", # omit the Id and ValueAttribute fields "&$filter=endswith(Measure,'_1')") # filter only Measure ending on '_1' ) }
Get the available datasets from open data portal statline.
cbs4_get_datasets( catalog = "CBS", convert_dates = TRUE, verbose = getOption("cbsodata4.verbose", FALSE), base_url = getOption("cbsodata4.base_url", BASEURL4) ) cbs4_get_toc( catalog = "CBS", convert_dates = TRUE, verbose = getOption("cbsodata4.verbose", FALSE), base_url = getOption("cbsodata4.base_url", BASEURL4) )
cbs4_get_datasets( catalog = "CBS", convert_dates = TRUE, verbose = getOption("cbsodata4.verbose", FALSE), base_url = getOption("cbsodata4.base_url", BASEURL4) ) cbs4_get_toc( catalog = "CBS", convert_dates = TRUE, verbose = getOption("cbsodata4.verbose", FALSE), base_url = getOption("cbsodata4.base_url", BASEURL4) )
catalog |
only show the datasets from that catalog. If |
convert_dates |
Converts date columns in Date-Time type (in stead of |
verbose |
Should the url request be printed? |
base_url |
base url of the CBS OData 4 API |
Setting the catalog to NULL
will return all
data.frame()
with publication metadata of tables.
the datasets are downloaded only once per R session and cached. Subsequent calls to
cbs4_get_datasets
will use the results of the first call.
Other datasets:
cbs4_get_catalogs()
if (interactive()){ # retrieve the main datasets (catalog = "CBS") ds <- cbs4_get_datasets() print(nrow(ds)) # see cbs4_get_catalogs() to retrieve all catalogs ds_asd <- cbs4_get_datasets(catalog = "CBS-asd") print(nrow(ds_asd)) ds_all <- cbs4_get_datasets(catalog = NULL) print(nrow(ds_all)) }
if (interactive()){ # retrieve the main datasets (catalog = "CBS") ds <- cbs4_get_datasets() print(nrow(ds)) # see cbs4_get_catalogs() to retrieve all catalogs ds_asd <- cbs4_get_datasets(catalog = "CBS-asd") print(nrow(ds_asd)) ds_all <- cbs4_get_datasets(catalog = NULL) print(nrow(ds_all)) }
Retrieve the metadata of a publication. The meta object contains all metadata properties of cbsodata in the form of data.frames.
cbs4_get_metadata( id, catalog = "CBS", ..., base_url = getOption("cbsodata4.base_url", BASEURL4), verbose = getOption("cbsodata4.verbose", FALSE) )
cbs4_get_metadata( id, catalog = "CBS", ..., base_url = getOption("cbsodata4.base_url", BASEURL4), verbose = getOption("cbsodata4.verbose", FALSE) )
id |
Identifier of publication or data retrieved with |
catalog |
Catalog, from the set of |
... |
not used |
base_url |
alternative url that implements same interface as statistics netherlands. |
verbose |
Should the function report on retrieving the data |
Each data.frame
describes properties of the CBS / Statistics
Netherlands
table: “Dimensions”, “MeasureCodes” and one ore more
“\<Dimension\>Codes” describing the meta data of the borders of a CBS
table.
if (interactive()){ meta <- cbs4_get_metadata("80416ned") print(names(meta)) # Dimension columns in the dataset meta$Dimensions # the metadata of the Measures/Topics meta$MeasureCodes # the metadata of the Perioden Categories meta$PeriodenCodes # all descriptive and publication meta data on this dataset meta$Properties }
if (interactive()){ meta <- cbs4_get_metadata("80416ned") print(names(meta)) # Dimension columns in the dataset meta$Dimensions # the metadata of the Measures/Topics meta$MeasureCodes # the metadata of the Perioden Categories meta$PeriodenCodes # all descriptive and publication meta data on this dataset meta$Properties }
Get observations from table id
. Observations are data of a CBS opendata table in so-called long
format.
cbs4_get_observations( id, ..., query = NULL, catalog = "CBS", download_dir = file.path(tempdir(), id), show_progress = interactive() && !verbose, verbose = getOption("cbsodata4.verbose", FALSE), sep = ",", includeId = TRUE, as.data.table = FALSE, base_url = getOption("cbsodata4.base_url", BASEURL4) )
cbs4_get_observations( id, ..., query = NULL, catalog = "CBS", download_dir = file.path(tempdir(), id), show_progress = interactive() && !verbose, verbose = getOption("cbsodata4.verbose", FALSE), sep = ",", includeId = TRUE, as.data.table = FALSE, base_url = getOption("cbsodata4.base_url", BASEURL4) )
id |
Identifier of the Opendata table. Can be retrieved with |
... |
optional selections on data, passed through to cbs4_download. See examples |
query |
optional query in odata4 syntax (overwrites any specification in |
catalog |
Catalog in which the dataset is to be found. |
download_dir |
directory in which the data and metadata is downloaded. By default this is temporary directory, but can be set manually |
show_progress |
if |
verbose |
if |
sep |
separator to be used to download the data. |
includeId |
|
as.data.table |
|
base_url |
Possible other url which implements same protocol. |
The returned data.frame()
has the following columns:
A Measure
column with identifiers/codes of measures/topics. Detailed information
on Measures can be found with in MeasureCodes
using cbs4_get_metadata()
.
Measure labels can be added with cbs4_add_label_columns()
.
A Value
column with the (numerical) value, Units can be added
with cbs4_add_unit_column()
.
An optional ValueAttribute
column with data point specific metadata.
For each dimension a separate column with category identifiers. Category
labels can be added with cbs4_add_label_columns()
or found in cbs4_get_metadata()
.
Date columns can be added with cbs4_add_date_column()
.
cbs4_get_data()
offers an alternative in which
each variable/topic/Measure has its own column.
data.frame()
or data.table()
object, see details.
Other data-download:
cbs4_download()
,
cbs4_get_data()
if (interactive()){ # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 ) # filter on multiple Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = c("2019MM12", "2020MM01") # december 2019, january 2020 ) # to filter on a dimension just add the filter to the query # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains cbs4_get_data("84287NED" , Perioden = contains("2020") , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with multiple contains cbs4_get_data("84287NED" , Perioden = contains(c("2019MM1", "2020")) , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains or = "2019MM12 cbs4_get_data("84287NED" , Perioden = contains("2020") | "2019MM12" , BedrijfstakkenBranchesSBI2008 = "T001081" ) # This all works on observations too cbs4_get_observations( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = contains("PV") # provinces , Measure = "M003371_2" # topic selection ) # supply your own odata 4 query cbs4_get_data("84287NED", query = "$filter=Perioden eq '2019MM12'") # an odata 4 query will overrule other filter statements cbs4_get_data("84287NED" , Perioden = "2018MM12" , query = "$filter=Perioden eq '2019MM12'" ) # With query argument an odata4 expression with other (filter) functions can be used cbs4_get_observations( id = "80784ned" # table id ,query = paste0( # odata4 query "$skip=4", # skip the first 4 rows of the filtered result "&$top=20", # then slice the first 20 rows of the filtered result "&$select=Measure,Geslacht,Perioden,RegioS,Value", # omit the Id and ValueAttribute fields "&$filter=endswith(Measure,'_1')") # filter only Measure ending on '_1' ) }
if (interactive()){ # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 ) # filter on multiple Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = c("2019MM12", "2020MM01") # december 2019, january 2020 ) # to filter on a dimension just add the filter to the query # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains cbs4_get_data("84287NED" , Perioden = contains("2020") , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with multiple contains cbs4_get_data("84287NED" , Perioden = contains(c("2019MM1", "2020")) , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains or = "2019MM12 cbs4_get_data("84287NED" , Perioden = contains("2020") | "2019MM12" , BedrijfstakkenBranchesSBI2008 = "T001081" ) # This all works on observations too cbs4_get_observations( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = contains("PV") # provinces , Measure = "M003371_2" # topic selection ) # supply your own odata 4 query cbs4_get_data("84287NED", query = "$filter=Perioden eq '2019MM12'") # an odata 4 query will overrule other filter statements cbs4_get_data("84287NED" , Perioden = "2018MM12" , query = "$filter=Perioden eq '2019MM12'" ) # With query argument an odata4 expression with other (filter) functions can be used cbs4_get_observations( id = "80784ned" # table id ,query = paste0( # odata4 query "$skip=4", # skip the first 4 rows of the filtered result "&$top=20", # then slice the first 20 rows of the filtered result "&$select=Measure,Geslacht,Perioden,RegioS,Value", # omit the Id and ValueAttribute fields "&$filter=endswith(Measure,'_1')") # filter only Measure ending on '_1' ) }
Search a opendata table using free text search.
cbs4_search( query, catalog = "CBS", language = "nl-nl", convert_dates = TRUE, verbose = getOption("cbsodata4.verbose", FALSE), base_url = getOption("cbsodata4.base_url", BASEURL4) )
cbs4_search( query, catalog = "CBS", language = "nl-nl", convert_dates = TRUE, verbose = getOption("cbsodata4.verbose", FALSE), base_url = getOption("cbsodata4.base_url", BASEURL4) )
query |
|
catalog |
only show the datasets from that catalog. If |
language |
|
convert_dates |
Converts date columns in Date-Time type (in stead of |
verbose |
Should the url request be printed? |
base_url |
base url of the CBS OData 4 API |
data.frame
same format as cbs4_get_datasets()
plus extra $rel
column
with the search score.
The search engine currently searches in the odata3 data collection, but uses the Identifiers to find tables in the odata4 data collection.
if (interactive()){ ds_nl <- cbs4_search("geboorte", language="nl-nl") ds_nl[1:3, c("Identifier", "Title", "rel")] bike_tables <- cbs4_search("fiets") bike_tables[1:10, c("Identifier", "Title", "rel")] }
if (interactive()){ ds_nl <- cbs4_search("geboorte", language="nl-nl") ds_nl[1:3, c("Identifier", "Title", "rel")] bike_tables <- cbs4_search("fiets") bike_tables[1:10, c("Identifier", "Title", "rel")] }
Detects a substring in a column and filters the dataset at CBS:
rows that have a code that does not contain (one of) x
are filtered out.
contains(x, column = NULL, allowed = NULL) has_substring(x, column = NULL, allowed = NULL)
contains(x, column = NULL, allowed = NULL) has_substring(x, column = NULL, allowed = NULL)
x |
substring to be detected in column |
column |
column name |
allowed |
|
Other odata4 query:
eq()
if (interactive()){ # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 ) # filter on multiple Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = c("2019MM12", "2020MM01") # december 2019, january 2020 ) # to filter on a dimension just add the filter to the query # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains cbs4_get_data("84287NED" , Perioden = contains("2020") , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with multiple contains cbs4_get_data("84287NED" , Perioden = contains(c("2019MM1", "2020")) , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains or = "2019MM12 cbs4_get_data("84287NED" , Perioden = contains("2020") | "2019MM12" , BedrijfstakkenBranchesSBI2008 = "T001081" ) # This all works on observations too cbs4_get_observations( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = contains("PV") # provinces , Measure = "M003371_2" # topic selection ) # supply your own odata 4 query cbs4_get_data("84287NED", query = "$filter=Perioden eq '2019MM12'") # an odata 4 query will overrule other filter statements cbs4_get_data("84287NED" , Perioden = "2018MM12" , query = "$filter=Perioden eq '2019MM12'" ) # With query argument an odata4 expression with other (filter) functions can be used cbs4_get_observations( id = "80784ned" # table id ,query = paste0( # odata4 query "$skip=4", # skip the first 4 rows of the filtered result "&$top=20", # then slice the first 20 rows of the filtered result "&$select=Measure,Geslacht,Perioden,RegioS,Value", # omit the Id and ValueAttribute fields "&$filter=endswith(Measure,'_1')") # filter only Measure ending on '_1' ) }
if (interactive()){ # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 ) # filter on multiple Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = c("2019MM12", "2020MM01") # december 2019, january 2020 ) # to filter on a dimension just add the filter to the query # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains cbs4_get_data("84287NED" , Perioden = contains("2020") , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with multiple contains cbs4_get_data("84287NED" , Perioden = contains(c("2019MM1", "2020")) , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains or = "2019MM12 cbs4_get_data("84287NED" , Perioden = contains("2020") | "2019MM12" , BedrijfstakkenBranchesSBI2008 = "T001081" ) # This all works on observations too cbs4_get_observations( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = contains("PV") # provinces , Measure = "M003371_2" # topic selection ) # supply your own odata 4 query cbs4_get_data("84287NED", query = "$filter=Perioden eq '2019MM12'") # an odata 4 query will overrule other filter statements cbs4_get_data("84287NED" , Perioden = "2018MM12" , query = "$filter=Perioden eq '2019MM12'" ) # With query argument an odata4 expression with other (filter) functions can be used cbs4_get_observations( id = "80784ned" # table id ,query = paste0( # odata4 query "$skip=4", # skip the first 4 rows of the filtered result "&$top=20", # then slice the first 20 rows of the filtered result "&$select=Measure,Geslacht,Perioden,RegioS,Value", # omit the Id and ValueAttribute fields "&$filter=endswith(Measure,'_1')") # filter only Measure ending on '_1' ) }
Detects for codes in a column. eq
filters the data set at CBS: rows that have
a code that is not in x
are filtered out.
eq(x, column = NULL, allowed = NULL)
eq(x, column = NULL, allowed = NULL)
x |
exact code(s) to be matched in |
column |
name of column. |
allowed |
|
query object
Other odata4 query:
contains()
if (interactive()){ # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 ) # filter on multiple Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = c("2019MM12", "2020MM01") # december 2019, january 2020 ) # to filter on a dimension just add the filter to the query # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains cbs4_get_data("84287NED" , Perioden = contains("2020") , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with multiple contains cbs4_get_data("84287NED" , Perioden = contains(c("2019MM1", "2020")) , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains or = "2019MM12 cbs4_get_data("84287NED" , Perioden = contains("2020") | "2019MM12" , BedrijfstakkenBranchesSBI2008 = "T001081" ) # This all works on observations too cbs4_get_observations( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = contains("PV") # provinces , Measure = "M003371_2" # topic selection ) # supply your own odata 4 query cbs4_get_data("84287NED", query = "$filter=Perioden eq '2019MM12'") # an odata 4 query will overrule other filter statements cbs4_get_data("84287NED" , Perioden = "2018MM12" , query = "$filter=Perioden eq '2019MM12'" ) # With query argument an odata4 expression with other (filter) functions can be used cbs4_get_observations( id = "80784ned" # table id ,query = paste0( # odata4 query "$skip=4", # skip the first 4 rows of the filtered result "&$top=20", # then slice the first 20 rows of the filtered result "&$select=Measure,Geslacht,Perioden,RegioS,Value", # omit the Id and ValueAttribute fields "&$filter=endswith(Measure,'_1')") # filter only Measure ending on '_1' ) }
if (interactive()){ # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 ) # filter on multiple Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = c("2019MM12", "2020MM01") # december 2019, january 2020 ) # to filter on a dimension just add the filter to the query # filter on Perioden (see meta$PeriodenCodes) cbs4_get_data("84287NED" , Perioden = "2019MM12" # december 2019 , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains cbs4_get_data("84287NED" , Perioden = contains("2020") , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with multiple contains cbs4_get_data("84287NED" , Perioden = contains(c("2019MM1", "2020")) , BedrijfstakkenBranchesSBI2008 = "T001081" ) # filter on Perioden with contains or = "2019MM12 cbs4_get_data("84287NED" , Perioden = contains("2020") | "2019MM12" , BedrijfstakkenBranchesSBI2008 = "T001081" ) # This all works on observations too cbs4_get_observations( id = "80784ned" # table id , Perioden = "2019JJ00" # Year 2019 , Geslacht = "1100" # code for total gender , RegioS = contains("PV") # provinces , Measure = "M003371_2" # topic selection ) # supply your own odata 4 query cbs4_get_data("84287NED", query = "$filter=Perioden eq '2019MM12'") # an odata 4 query will overrule other filter statements cbs4_get_data("84287NED" , Perioden = "2018MM12" , query = "$filter=Perioden eq '2019MM12'" ) # With query argument an odata4 expression with other (filter) functions can be used cbs4_get_observations( id = "80784ned" # table id ,query = paste0( # odata4 query "$skip=4", # skip the first 4 rows of the filtered result "&$top=20", # then slice the first 20 rows of the filtered result "&$select=Measure,Geslacht,Perioden,RegioS,Value", # omit the Id and ValueAttribute fields "&$filter=endswith(Measure,'_1')") # filter only Measure ending on '_1' ) }