knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
This library is in early development, if you face any problem please open an issue
R Client to access the data portal's API of King Abdullah Petroleum Studies and Research Center
The documentations of the API can be found here
devtools::install_github("naif-alsader/KapsarcR")
library(KapsarcR) library(tidyverse) datasets<-list_datasets()
The dataset returned from list_datasets()
is not tidy. You can use clean_dataset()
to get a more tidy dataset
datasets %>% clean_dataset() %>% head()
and the column names are
datasets %>% clean_dataset() %>% colnames()
# by Country datasets<-list_datasets(country = "Saudi Arabia") # by Theme datasets<-list_datasets(theme = "Water") # by Keyword datasets<-list_datasets(keyword = "Water")
There are two ways filter two arguments:
if both arguments appear together (use operation = and
) the default value
if either argument one or two appears (use operation = or
)]
datasets<-list_datasets(keyword = "Water", theme = "Water", operation = "or")
datasets<-list_datasets(q = "default.theme = 'Water' or default.theme = 'Transportation'") datasets<-list_datasets(q = "default.modified > '2019'") datasets<-list_datasets(q = "default.records_count > 1000000")
The fields that can be used in the query can be found in the meta column (its actually 4 datasets in one column) of the dataset datasets$metas$default
or datasets$metas$custom
here is the complete list:
datasets$metas$default %>% colnames() %>% paste0(" default.", .) %>% pander::pander()
datasets$metas$custom %>% colnames() %>% paste0(" custom.", .) %>% pander::pander()
datasets$metas$dcat %>% colnames() %>% paste0(" dcat.", .) %>% pander::pander()
df <- get_dataset(datasets$dataset_id[1])
library(purrr) df_list <- map(datasets$dataset_id, get_dataset)
attachments <- get_attachments(datasets$dataset_id[1])
attachments_list <- map(datasets$dataset_id, get_attachments)
download_attachments(attachments)
map(attachments_list, download_attachments)
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.