Comments (3)
Hi Edwin,
Thank you for providing such an accessible package to retrieve CBS data with.
I had a question regarding the cbs_get_themes functionality. I wondered if I could filter the request on the basis of if a dataset withholds information about a particular city in the Netherlands?
This is the code that I use at the moment:
#-------------------------------Load packages-------------------------------------------------
library(cbsodataR)
library(dplyr)
#-------------------------------retrieve meta information CBS-----------------------------------
tbl.lijst <- cbs_get_toc(Language = "nl")
##-----------------------------------table description-------------------------------------------
DF <- tbl.lijst %>%
select(Identifier, ShortTitle)
tbl.lijst
##Store table description
Setwd(Output.meta)
Write.csv(Tbl.lijst[3:4], file = "lijst.csv")
And now I am wondering if I could also filter on a particular city/region besides filtering on the language of the dataset?
I would like to thank you in advance for answering my question!
Kind regards,
Tobias
from cbsodatar.
You're welcome!
Regarding your question:
the cbs_get_toc
allows to filter on values of each of the columns. (just use <columnname>="<value>"
in the function).
The table of contents however does not have a regions column, to do a direct filter, however the following script should help you get on your way:
library(cbsodataR)
# checking a table with "gemeente" data
meta <- cbs_get_meta(id ="70748ned")
# meta contains several meta data table including the RegioS or Gemeenten table
View(meta$Gemeenten) # find out which gemeente you want to select.
# Note, the keys may contain spaces...
# Let us select the first "gemeente" Alkmaar
ALKMAAR <- meta$Gemeenten$Key[2]
# We can retrieve data for ALKMAAR
dat <- cbs_get_data(id = "70748ned", Gemeenten = ALKMAAR)
# or we can find out which tables contain ALKMAAR
toc <- cbs_get_toc(Language = "nl")
# takes a long time...
contains_alkmaar <- sapply(toc$Identifier, function(x){
cat(".")
meta <- cbs_get_meta(x)
if (!is.null(meta$RegioS)){
ALKMAAR %in% meta$RegioS$Key
} else if (!is.null(meta$Gemeenten)){
ALKMAAR %in% meta$Gemeenten$Key
} else {
FALSE
}
})
toc_with_alkmaar <- toc[which(contains_alkmaar),]
from cbsodatar.
Hi Edwin,
Thank you for providing this piece of code. When I run the function it returns the following error:
Error during wrapup: Forbidden (HTTP 403). Failed to Client error: (403) Forbidden.
Basically indicating that the request that the function is asking will not be full-filled. Is there anyway to workaround this?
I tried putting Sys.sleep() in the function to slowly ask the server for information, but this did not solve the problem.
Appreciate the provided tips.
Kind regards,
Tobias
from cbsodatar.
Related Issues (20)
- More informative error message when request too long
- problems loading 70747ned HOT 19
- error bij `cbs_add_columns()` HOT 3
- please document output values HOT 3
- cbs_get_meta() gives error: fixed but not yet on CRAN HOT 2
- filter data with geq, neq and not in HOT 3
- week periods are not converted with `cbs_add_date_column` HOT 4
- cbsodataR in Remoteacces environment HOT 7
- setwd() in package limits cronjobs HOT 4
- `cbs_get_data` with `base_url="http://dataderden.cbs.nl` fails HOT 2
- Solution for no connection with Windows 7/8 and IE11
- cbs_get_data() no response error
- Filter not working in cbs_get_data, on column SoortRegio_2 HOT 4
- error cbs_download_data HOT 1
- HTTP versus HTTPS
- method to keep track of table updates? HOT 1
- `cbs_download_data`: catalog error
- `cbs_get_data` argument `typed=FALSE` not working correctly
- `cbs_get_meta`: default selection which includes a substring of is not parsed correctly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cbsodatar.