-
Catalogue management. baRcelona is used to consult and manage the catalogue information available on the Open Data BCN portal, such as data sets and their associated resources: ID, topic, author, source, department, etc.
-
Retrieve CSV files. Allows you to extract any CSV data set and load it directly in your RStudio environment.
# install.packages("devtools")
devtools::install_github("xavivg91/baRcelona")
library(baRcelona)
will load the following core functions:
datasetlist()
, for catalogue management.
# Retrieves all the current data sets
datasetlist()
# You can filter by topic
datasetlist(topic = c("Administration", "City and Services", "Economy and Business", "Population",
"Territory"))
# ... and you can also filter by more specific topics
datasetlist(subtopic = c("Culture and Leisure", "Demography", "Education", "Employment",
"Environment", "Housing", "Human resources", "Legislation and justice",
"Participation", "Procurement", "Public opinion", "Public sector",
"Science and technology", "Security", "Society and Welfare",
"Sport", "Tourism", "Town planning and Infrastructures", "Trade",
"Transport"))
get.csv()
, for CSV data sets.
Let’s say we want to obtain a data set related to sports. First, we need to execute the dataselist()
function to see all the
sports data sets available on the Open Data BCN portal.
# List of sports data sets available on the portal
datasets <- datasetlist(subtopic = "Sport")
Once executed, check out the saved data frame and copy the resource ID of the CSV you want to consult (inside the ID column).
Then, paste the ID as an input argument of the get.csv()
function.
# Save the CSV data set in your RStudio environment
sportdataset <- get.csv(id = "bee7897a-9088-4ab1-ba4b-de7f68cf7fc5")
Easy peasy, right?
All extracted baRcelona data belong to the Open Data BCN portal.