Title: | A Client for the Humanitarian Data Exchange platform API |
---|---|
Description: | Client for the Humanitarian Data Exchange (HDX) platform API <https://data.humdata.org>. Allows to search and download HDX datasets into R. |
Authors: | Ahmadou Dicko [aut, cre] |
Maintainer: | Ahmadou Dicko <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2024-11-24 03:10:54 UTC |
Source: | https://github.com/dickoa/rhdx |
List datasets
.list_datasets(limit = NULL, offset = NULL, configuration = NULL) list_datasets(limit = NULL, offset = NULL, configuration = NULL)
.list_datasets(limit = NULL, offset = NULL, configuration = NULL) list_datasets(limit = NULL, offset = NULL, configuration = NULL)
limit |
integer; limit |
offset |
integer; offset |
configuration |
a Configuration object |
A vector of datasets names
## Not run: # Setting the config to use HDX default server set_rhdx_config() list_datasets(limit = 10L) ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() list_datasets(limit = 10L) ## End(Not run)
List HDX organization
.list_organizations( sort = "name asc", all_fields = FALSE, include_dataset_count = TRUE, include_groups = FALSE, include_user = FALSE, include_tags = FALSE, configuration = NULL, ... ) list_organizations( sort = "name asc", all_fields = FALSE, include_dataset_count = TRUE, include_groups = FALSE, include_user = FALSE, include_tags = FALSE, configuration = NULL, ... )
.list_organizations( sort = "name asc", all_fields = FALSE, include_dataset_count = TRUE, include_groups = FALSE, include_user = FALSE, include_tags = FALSE, configuration = NULL, ... ) list_organizations( sort = "name asc", all_fields = FALSE, include_dataset_count = TRUE, include_groups = FALSE, include_user = FALSE, include_tags = FALSE, configuration = NULL, ... )
sort |
Character how to sort the results. Default is "name asc" |
all_fields |
Logical, include all fields |
include_dataset_count |
Logical include count in the result |
include_groups |
Logical, whether or not to include locations |
include_user |
Logical, whether or not to include user |
include_tags |
Logical whether or not to include tags |
configuration |
Configuration |
... |
extra paramaters |
A list of organizations on HDX
List all authorized tags in HDX
authorized_tags(configuration = NULL)
authorized_tags(configuration = NULL)
configuration |
Configuration |
A vector of character, the authorized tags name
## Not run: autorized_tags() ## End(Not run)
## Not run: autorized_tags() ## End(Not run)
Browse a HDX object
## S3 method for class 'Dataset' browse(x, ...) ## S3 method for class 'Organization' browse(x, ...) ## S3 method for class 'HDXResource' browse(x, ...) ## S3 method for class 'HDXUser' browse(x, ...) browse(x, ...) ## Default S3 method: browse(x, ...)
## S3 method for class 'Dataset' browse(x, ...) ## S3 method for class 'Organization' browse(x, ...) ## S3 method for class 'HDXResource' browse(x, ...) ## S3 method for class 'HDXUser' browse(x, ...) browse(x, ...) ## Default S3 method: browse(x, ...)
x |
an HDX object |
... |
Extra parameters |
Character Tags of the dataset
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) browse(res[[1]]) ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) browse(res[[1]]) ## End(Not run)
Count all datasets on HDX
count_datasets(configuration = NULL)
count_datasets(configuration = NULL)
configuration |
an HDX Configuration object |
An integer, the number of datasets
Create and HDX configuration object
create_rhdx_config( hdx_site = "prod", hdx_key = NULL, read_only = TRUE, hdx_config = NULL, hdx_config_file = NULL )
create_rhdx_config( hdx_site = "prod", hdx_key = NULL, read_only = TRUE, hdx_config = NULL, hdx_config_file = NULL )
hdx_site |
Character to specify which HDX server you want to use. Default to "prod". |
hdx_key |
Character for the CKAN API key, it is required to push data into HDX |
read_only |
Logical if |
hdx_config |
List of HDX configuration |
hdx_config_file |
Character, path of the HDX config file in JSON and YAML format |
An HDX Configuration object
Delete resource from dataset
delete_resource(dataset, index)
delete_resource(dataset, index)
dataset |
Dataset the dataset from which we one to remove the resource |
index |
Integer the index of the resource to be removed |
Delete resource from dataset
Dataset the dataset without the resource
Delete all resource from dataset
delete_resources(dataset)
delete_resources(dataset)
dataset |
A Dataset, the dataset to remove |
Delete all resources from dataset
Dataset without resources
Delete the configuration settings for using rhdx.
delete_rhdx_config()
delete_rhdx_config()
Delete HDX config
None
## Not run: # Setting the config to use HDX default server set_rhdx_config(hdx_site = "prod") get_rhdx_config() delete_rhdx_config() get_rhdx_config() ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config(hdx_site = "prod") get_rhdx_config() delete_rhdx_config() get_rhdx_config() ## End(Not run)
Download an HDX resource into a specific folder
download_resource( resource, folder = NULL, filename = NULL, quiet = FALSE, force = FALSE, ... )
download_resource( resource, folder = NULL, filename = NULL, quiet = FALSE, force = FALSE, ... )
resource |
Resource, an HDX resource |
folder |
character, path of the directory where you will store the data |
filename |
(character), name of the file you will download |
quiet |
(logical), no progress bar from download (default = |
force |
(logical) force download (default = |
... |
extra paramaters |
Resource
## Not run: #Setting the config to use HDX default server res <- read_resource("98aa1742-b5d3-40c3-94c6-01e31ded6e84") download_resource(res, folder = "/tmp") ## End(Not run)
## Not run: #Setting the config to use HDX default server res <- read_resource("98aa1742-b5d3-40c3-94c6-01e31ded6e84") download_resource(res, folder = "/tmp") ## End(Not run)
Date of dataset
get_dataset_date(dataset)
get_dataset_date(dataset)
dataset |
Dataset |
Date, date of the dataset
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) get_dataset_date(res[[1]]) ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) get_dataset_date(res[[1]]) ## End(Not run)
Gets locations name from the datasets
get_locations_names(dataset)
get_locations_names(dataset)
dataset |
Dataset |
Character locations of the dataset
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) get_location_names(res[[1]]) ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) get_location_names(res[[1]]) ## End(Not run)
Get the organization sharing the data
get_organization_name(dataset)
get_organization_name(dataset)
dataset |
Dataset |
Character The name of the organization sharing the data
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) get_organization_name(res[[1]]) ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) get_organization_name(res[[1]]) ## End(Not run)
Add resource to dataset
get_resource(dataset, index)
get_resource(dataset, index)
dataset |
Dataset |
index |
integer; resource position in the dataset |
Resource
Get the dataset containing the resource
get_resource_dataset(resource)
get_resource_dataset(resource)
resource |
Resource, an HDX resource |
a Dataset, the dataset containing the resource
Get the file format of the resource
get_resource_format(resource)
get_resource_format(resource)
resource |
Resource, an HDX resource |
A character, the format of the resource
List layers available in spatial resources on HDX
get_resource_layers( resource, format = NULL, download_folder = NULL, quiet = TRUE )
get_resource_layers( resource, format = NULL, download_folder = NULL, quiet = TRUE )
resource |
Resource, an HDX resource |
format |
character; file format |
download_folder |
Character, path of the directory where you will store the data |
quiet |
Logical, no progress bar from download (default = FALSE) |
the layers name
Get the names of the sheets of XLS(X) resources
get_resource_sheets( resource, format = NULL, download_folder = NULL, quiet = TRUE )
get_resource_sheets( resource, format = NULL, download_folder = NULL, quiet = TRUE )
resource |
Resource, an HDX resource |
format |
character; file format |
download_folder |
character, path of the directory where you will store the data |
quiet |
logical, no progress bar from download (default = FALSE) |
the names of the sheets of XLS(X) resources
Add resource to dataset
get_resources(dataset, pattern = NULL, format = NULL)
get_resources(dataset, pattern = NULL, format = NULL)
dataset |
Dataset |
pattern |
regex pattern in resource name |
format |
format of the resources |
resource_list
Gets format of all resources from the datasets
get_resources_formats(dataset)
get_resources_formats(dataset)
dataset |
Dataset |
Character Format of the resources
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) get_resources_formats(res[[1]]) ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) get_resources_formats(res[[1]]) ## End(Not run)
Gets dataset tags name
get_tags_names(dataset)
get_tags_names(dataset)
dataset |
Dataset |
Character Tags of the dataset
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) get_tags_names(res[[1]]) ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- search_dataset(rows = 3L) get_tags_names(res[[1]]) ## End(Not run)
Get some stats about HDX
hdx_general_statistics()
hdx_general_statistics()
A list
HDX Configuration
HDX Configuration
HDX Configuration allow to connect to an HDX server and setup project where you can interact with the HDX platform
data
all info in list.
new()
Create a new Configuration object.
HDXConfig$new( hdx_site = "prod", hdx_key = NULL, hdx_config = NULL, hdx_config_file = NULL, read_only = TRUE, user_agent = NULL )
hdx_site
character the server instance to use
hdx_key
character, the HDX API key
hdx_config
configuration in a list
hdx_config_file
a character value config file. default is the config supplied in the package
read_only
a logical value indicating if you want to just read or be also able to write on the HDX server. You will need a API key to write.
user_agent
a character value, User agent
A new Configuration object.
get_credentials()
Configuration credentials when using a HDX API key
HDXConfig$get_credentials()
the username and password associated to the HDX API key
set_read_only()
Create or revoke read only status
HDXConfig$set_read_only(read_only = TRUE)
read_only
a logical value indicating if you want to just read or be also able to write on the HDX server. You will need a API key to write.
set_hdx_key()
Specify a HDX API key
HDXConfig$set_hdx_key(hdx_key)
hdx_key
a character with key
get_hdx_key()
Specify a HDX API key
HDXConfig$get_hdx_key()
a character, the HDX API key
set_hdx_site()
Specify a HDX server to use
HDXConfig$set_hdx_site(hdx_site = "prod")
hdx_site
a character, the server type to use,
prod
, test
, feature
or demo
a character, the HDX API key
get_hdx_site()
Get the HDX server in use
HDXConfig$get_hdx_site()
the server type
get_hdx_site_url()
Get the HDX server URL in use
HDXConfig$get_hdx_site_url()
the server URL
remoteclient()
Get the remoteclient currently used
HDXConfig$remoteclient()
a crul::HttpClient
call_action()
Call the client to the HDX API
HDXConfig$call_action(action, ..., verb = "get")
action
a character
...
parameters for each verb used
verb
a character the verb used, post
, get
, put
or patch
list a with status code and results
read()
read and show Configuration object
HDXConfig$read()
Configuration object
setup()
Setup Configuration object
HDXConfig$setup( hdx_site = "prod", hdx_key = NULL, read_only = TRUE, hdx_config = NULL, configuration = NULL )
hdx_site
a character value, the server
hdx_key
a character value, the API key
read_only
a logical value read only
hdx_config
a list
configuration
a character
delete()
Delete a Configuration object Access the global Configuration
HDXConfig$delete()
get_global_config()
HDXConfig$get_global_config()
list with HDX configuration information
general_statistics()
Get general statistics about the server
HDXConfig$general_statistics()
list with statistics about the server
as_list()
Convert configuration to list
HDXConfig$as_list()
configuration in list format
print()
Print Configuration object
HDXConfig$print()
clone()
The objects of this class are cloneable with this method.
HDXConfig$clone(deep = FALSE)
deep
Whether to make a deep clone.
## Not run: set_rhdx_config(hdx_site = "prod") get_rhd_config() ## End(Not run)
## Not run: set_rhdx_config(hdx_site = "prod") get_rhd_config() ## End(Not run)
HDX Dataset
HDX Dataset
Dataset class containing all logic for accessing, creating, and updating datasets and associated resources.
rhdx::HDXObject
-> HDXDataset
resources
list of Resource object within the dataset
data
placeholder for Dataset field element
new()
Create a new Dataset object
HDXDataset$new(initial_data = NULL, configuration = NULL)
initial_data
list with required field to create a dataset
configuration
a Configuration object
A Dataset object
get_resource()
Get a specific resource of the dataset
HDXDataset$get_resource(index)
index,
the index of the resource to access
a Resource object, the selected resource
get_resources()
Get all resources of the dataset
HDXDataset$get_resources(pattern = NULL, format = NULL)
pattern
regex pattern in resource name
format
format of the resources
a list of Resource objects, all resources available in the dataset
number_of_resources()
Get number of dataset resources
HDXDataset$number_of_resources()
The number of Resource objects
delete_resource()
Delete a resource by its index
HDXDataset$delete_resource(index = 1L)
index,
the index of the resource to delete
delete_resources()
Delete all resources from a dataset
HDXDataset$delete_resources()
browse()
Browse the dataset page on HDX
HDXDataset$browse()
get_configuration()
Get the current configuration in use
HDXDataset$get_configuration()
A configuration object, the configuration in use
get_dataset_date()
Get the dataset date
HDXDataset$get_dataset_date()
a date, the dataset date.
get_update_frequency()
Get dataset update frequency
HDXDataset$get_update_frequency()
a character, the dataset update frequency Get dataset tags
get_tags()
HDXDataset$get_tags()
a list of Tag objects, datasets tags
get_locations()
Get the datasets location
HDXDataset$get_locations()
a list of Location objects, all locations covered by the dataset
get_maintainer()
Get the dataset maintainer
HDXDataset$get_maintainer()
An User object, the maintainer of the dataset
get_organization()
Get the dataset organization
HDXDataset$get_organization()
an Organization object, the organization that shared the data
get_showcases()
Get the Showcase associated to the dataset
HDXDataset$get_showcases()
a Showcase object containing the dataset
is_requestable()
Check if the dataset is requestable
HDXDataset$is_requestable()
a logical value, TRUE
if it's a requestable dataset
get_required_fields()
Get dataset required fields
HDXDataset$get_required_fields()
list of required fields for a dataset
check_required_fields()
Check dataset required field
HDXDataset$check_required_fields()
a logical value, TRUE if the the dataset is not missing a required field and throws an error otherwise
as_list()
Get dataset field into list
HDXDataset$as_list()
a list with dataset field
print()
Print a Dataset object
HDXDataset$print()
clone()
The objects of this class are cloneable with this method.
HDXDataset$clone(deep = FALSE)
deep
Whether to make a deep clone.
HDX Location
HDX Location
HDX location mostly countries
rhdx::HDXObject
-> HDXLocation
data
placeholder location
new()
Create a new Location object
HDXLocation$new(initial_data = NULL, configuration = NULL)
initial_data
list with required field to create a dataset
configuration
a Configuration object
A Location object
get_required_fields()
Get dataset required fields
HDXLocation$get_required_fields()
list of required fields for a dataset
check_required_fields()
Check dataset required field
HDXLocation$check_required_fields()
a logical value, TRUE if the the dataset is not missing a required field and throws an error otherwise
browse()
Browser the Location page on HDX
HDXLocation$browse()
as_list()
Get location field into list
HDXLocation$as_list()
a list with dataset field
print()
Print a Dataset object
HDXLocation$print()
clone()
The objects of this class are cloneable with this method.
HDXLocation$clone(deep = FALSE)
deep
Whether to make a deep clone.
HDXObject abstract class
HDXObject abstract class
HDXObject class containing all logic for accessing, creating, and updating HDX objects.
data
placeholder for HDXObject field element
new()
Create a new HDXObject object
HDXObject$new(initial_data = NULL, configuration = NULL)
initial_data
list with required field to create a HDXObject
configuration
a Configuration object
A HDXObject object
update_from_yaml()
Update metadata from yaml file
HDXObject$update_from_yaml(path)
path
(character) Path to YAML metadata
update_from_json()
Update metadata from json file
HDXObject$update_from_json(path)
path
(character) Path to JSON metadata
get_required_fields()
Get HDXObject required fields
HDXObject$get_required_fields()
list of required fields for a resource
check_required_field()
Check HDXobject required field
HDXObject$check_required_field()
a logical value, TRUE if the the resource is not missing a required field and throws an error otherwise
as_list()
Get HDXObject field into list
HDXObject$as_list()
a list with HDXObject field
browse()
Browse HDX
HDXObject$browse()
get_configuration()
Get the current configuration in use
HDXObject$get_configuration()
A configuration object, the configuration in use
print()
Print a Dataset object
HDXObject$print()
clone()
The objects of this class are cloneable with this method.
HDXObject$clone(deep = FALSE)
deep
Whether to make a deep clone.
HDX Organization
HDX Organization
HDX Organization
rhdx::HDXObject
-> HDXOrganization
data
placeholder for the Organization fields element
new()
Create a Organization object
HDXOrganization$new(initial_data = NULL, configuration = NULL)
initial_data
list with required field to create a dataset
configuration
a Configuration object
A Organization object
get_datasets()
Get the list of datasets within the organization
HDXOrganization$get_datasets()
list of Dataset objects
browse()
Browse the Organization page on HDX
HDXOrganization$browse()
as_list()
Get dataset field into list
HDXOrganization$as_list()
a list with organization field element
print()
Print a Dataset object
HDXOrganization$print()
clone()
The objects of this class are cloneable with this method.
HDXOrganization$clone(deep = FALSE)
deep
Whether to make a deep clone.
HDX Resource
HDX Resource
HDX Resource, it contains all the logic for creating, checking, and updating resources
rhdx::HDXObject
-> HDXResource
data
placeholder for Resource field element
new()
Create a new Resource object
HDXResource$new(initial_data = NULL, configuration = NULL)
initial_data
list with required field to create a resource
configuration
a Configuration object
A new Resource object
download()
Download a HDX resource
HDXResource$download( folder = NULL, filename = NULL, quiet = TRUE, force = FALSE, ... )
folder
a character, folder to save the dataset
filename
a character, filename of the dataset
quiet
a logical value, silent download if TRUE
force
a logical value, force download
...
other download.file
parameters
a character, the file path
download_folder()
Get the download folder for the latest downloaded resource
HDXResource$download_folder()
a character, folder with the latest downloaded resource
read_resource()
Read a Resource object directly into memory
HDXResource$read_resource( sheet = NULL, layer = NULL, format = NULL, download_folder = NULL, simplify_json = TRUE, force_download = FALSE, quiet_download = TRUE, ... )
sheet
a character value, only for resource in Excel format
layer
a character value, only for spatial (vector) resource
format
a character value, file format;
download_folder
a character value, folder to save the downloaded resource
simplify_json
a logical value
force_download
a logical value, if TRUE force download
quiet_download
a logical value, if TRUE silent download
...
other parameters
a tibble
, a sf
, a stars
or a list
depending
on the type of resource read
get_layers()
Get spatial (vector) resource list of layers
HDXResource$get_layers( format = NULL, download_folder = NULL, quiet_download = TRUE, force_download = FALSE )
format
character; file format
download_folder
a character value, folder to save the downloaded resource
quiet_download
a logical value, if TRUE silent download
force_download
a logical value, if TRUE force download
a the list of layers available in the resource
get_sheets()
Get the list of sheets name of resource
HDXResource$get_sheets( format = NULL, download_folder = NULL, quiet_download = TRUE, force_download = FALSE )
format
character; file format
download_folder
a character value, folder to save the downloaded resource
quiet_download
a logical value, if TRUE silent download
force_download
a logical value, if TRUE force download
a the list of layers available in the resource
get_dataset()
Get the resource dataset.
HDXResource$get_dataset()
a Dataset, the dataset containing the resource
get_required_fields()
Get dataset required fields
HDXResource$get_required_fields()
list of required fields for a resource
check_required_field()
Check dataset required field
HDXResource$check_required_field(check_dataset_id = FALSE)
check_dataset_id
logical whether to check or not dataset id
a logical value, TRUE if the the resource is not missing a required field and throws an error otherwise
get_format()
Get the file format
HDXResource$get_format()
a character, the file format of the resource
as_list()
Get resource field into list
HDXResource$as_list()
a list with resource field
browse()
Browse the resource page on HDX
HDXResource$browse()
print()
Print a Resource object
HDXResource$print()
clone()
The objects of this class are cloneable with this method.
HDXResource$clone(deep = FALSE)
deep
Whether to make a deep clone.
HDX Showcase
HDX Showcase
HDX Showcase
rhdx::HDXObject
-> HDXShowcase
datasets
list of datasets using this showcase
data
the field info into list
new()
Create a new Showcase object
HDXShowcase$new(initial_data = NULL, configuration = NULL)
initial_data
list, data with required field to create Showcase
configuration
Configuration, configuration to use
a new Showcase object
get_datasets()
List datasets using the Showcase
HDXShowcase$get_datasets()
a list of dataset
browse()
Browse the Showcase page on HDX
HDXShowcase$browse()
as_list()
Get dataset field into list
HDXShowcase$as_list()
a list with showcase field info
print()
Print a Showcase object
HDXShowcase$print()
clone()
The objects of this class are cloneable with this method.
HDXShowcase$clone(deep = FALSE)
deep
Whether to make a deep clone.
HDX User
HDX User
HDX user
rhdx::HDXObject
-> HDXUser
data
placeholder for Dataset field element
new()
Create a new
HDXUser$new(initial_data = NULL, configuration = NULL)
initial_data
list of field required to create a dataset
configuration
Configuration configuration to use
a new User object
as_list()
Get dataset field into list
HDXUser$as_list()
a list with dataset field
browse()
Browse the user page on HDX
HDXUser$browse()
print()
Print a User object
HDXUser$print()
clone()
The objects of this class are cloneable with this method.
HDXUser$clone(deep = FALSE)
deep
Whether to make a deep clone.
List locations
list_locations( sort = "name asc", all_fields = FALSE, configuration = NULL, ... )
list_locations( sort = "name asc", all_fields = FALSE, configuration = NULL, ... )
sort |
Character sorting of the search results. Default: “name asc”, the allowed fields are ‘name’, ‘package_count’ and ‘title’ |
all_fields |
Logical if TRUE returns list instead of just names |
configuration |
a Configuration |
... |
Extra parameters to group_list https://docs.ckan.org/en/ckan-2.8.2/api/index.html#ckan.logic.action.get.group_list |
A vector of locations names
## Not run: # Setting the config to use HDX default server set_rhdx_config() list_locations(limit = 10L) ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() list_locations(limit = 10L) ## End(Not run)
List all available tags
list_tags( query = NULL, vocabulary_id = NULL, all_fields = FALSE, configuration = NULL )
list_tags( query = NULL, vocabulary_id = NULL, all_fields = FALSE, configuration = NULL )
query |
a tag name query to search for, if given only tags whose names contain this string will be returned |
vocabulary_id |
the id or name of a vocabulary, if give only tags that belong to this vocabulary will be returned |
all_fields |
logical return full Tag object instead of just names |
configuration |
Configuration the configuration to use |
## Not run: # Setting the config to use HDX default server set_rhdx_config() list_tag() ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() list_tag() ## End(Not run)
List all users
list_users(order_by = "number_created_packages", configuration = NULL, ...)
list_users(order_by = "number_created_packages", configuration = NULL, ...)
order_by |
Logical user sorted is TRUE |
configuration |
Configuration the configuration to use |
... |
Extra parameters |
## Not run: # Setting the config to use HDX default server set_rhdx_config() list_user() ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() list_user() ## End(Not run)
List available HDX Vocabulary objects
list_vocabularies(identifier = NULL, configuration = NULL)
list_vocabularies(identifier = NULL, configuration = NULL)
identifier |
character identifier |
configuration |
Configuration |
A list of Vocabulary object
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- list_vocabularies() res ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- list_vocabularies() res ## End(Not run)
Read an HDX dataset from its name or id
pull_dataset(identifier, configuration = NULL)
pull_dataset(identifier, configuration = NULL)
identifier |
Character dataset keyword |
configuration |
a Configuration object |
Dataset the dataset
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- pull_dataset("mali-3wop") res ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- pull_dataset("mali-3wop") res ## End(Not run)
Read an HDX location
pull_location( identifier = NULL, include_datasets = FALSE, configuration = NULL, ... )
pull_location( identifier = NULL, include_datasets = FALSE, configuration = NULL, ... )
identifier |
Character location uuid |
include_datasets |
Logical whether to include or not dataset |
configuration |
Configuration a configuration object |
... |
Extra parameters |
Location
## Not run: #Setting the config to use HDX default server set_rhdx_config() res <- pull_location("mli") res ## End(Not run)
## Not run: #Setting the config to use HDX default server set_rhdx_config() res <- pull_location("mli") res ## End(Not run)
Read an HDX organization
pull_organization( identifier = NULL, include_datasets = FALSE, configuration = NULL, ... )
pull_organization( identifier = NULL, include_datasets = FALSE, configuration = NULL, ... )
identifier |
character resource uuid |
include_datasets |
Logical, include datasets if TRUE |
configuration |
an HDX configuration object |
... |
Extra parameters |
HDX organization
Read an HDX resource
pull_resource(identifier, configuration = NULL)
pull_resource(identifier, configuration = NULL)
identifier |
Character resource uuid |
configuration |
a Configuration object |
Resource
## Not run: #Setting the config to use HDX default server set_rhdx_config() res <- pull_resource("98aa1742-b5d3-40c3-94c6-01e31ded6e84") res ## End(Not run)
## Not run: #Setting the config to use HDX default server set_rhdx_config() res <- pull_resource("98aa1742-b5d3-40c3-94c6-01e31ded6e84") res ## End(Not run)
Read HDX Showcase
pull_showcase(identifier = NULL, configuration = NULL)
pull_showcase(identifier = NULL, configuration = NULL)
identifier |
Character Showcase name or id |
configuration |
Configuration an HDX configuration object |
Delete resource from dataset
A showcase
## Not run: # Setting the config to use HDX default server pull_showcase("fts-requirements-and-funding-data-for-zimbabwe-showcase") # first resource ## End(Not run)
## Not run: # Setting the config to use HDX default server pull_showcase("fts-requirements-and-funding-data-for-zimbabwe-showcase") # first resource ## End(Not run)
Read an HDX tag from its name or id
pull_tag( identifier = NULL, vocabulary_id = NULL, include_datasets = FALSE, configuration = NULL )
pull_tag( identifier = NULL, vocabulary_id = NULL, include_datasets = FALSE, configuration = NULL )
identifier |
character the name or id of the tag |
vocabulary_id |
character the id or name of the tag vocabulary that the tag is in - if it is not specified it will assume it is a free tag. |
include_datasets |
logical, include a list of the tag’s datasets. |
configuration |
a Configuration object |
Tag the tag
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- pull_tag("covid19") res ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- pull_tag("covid19") res ## End(Not run)
Read an HDX user from its name or id
pull_user( identifier = NULL, include_datasets = FALSE, configuration = NULL, ... )
pull_user( identifier = NULL, include_datasets = FALSE, configuration = NULL, ... )
identifier |
character user keyword |
include_datasets |
Logical, if TRUE add datasets |
configuration |
a Configuration object |
... |
Extra parameters |
User the user
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- pull_user("xxxx") res ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- pull_user("xxxx") res ## End(Not run)
Read an HDX vocabulary from its name or id
pull_vocabulary(identifier = NULL, configuration = NULL)
pull_vocabulary(identifier = NULL, configuration = NULL)
identifier |
character the name or id of the vocabulary |
configuration |
Configuration |
The Vocabulary object
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- pull_vocabulary("xxxx") res ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config() res <- pull_vocabulary("xxxx") res ## End(Not run)
Read resource
read_resource( resource, sheet = NULL, layer = NULL, format = NULL, download_folder = NULL, simplify_json = TRUE, force_download = FALSE, quiet_download = TRUE, ... )
read_resource( resource, sheet = NULL, layer = NULL, format = NULL, download_folder = NULL, simplify_json = TRUE, force_download = FALSE, quiet_download = TRUE, ... )
resource |
Resource, an HDX resource |
sheet |
Character, the name of the sheet to read if XLS(X) resources. The first sheet is read by default. |
layer |
Character, the name of the layer to read if spatial data. The first sheet is read by default. |
format |
Character, file format, csv, zipped csv, excel, xlsx, zipped shapefile, etc. |
download_folder |
Character, the path of the folder to store the downloaded data |
simplify_json |
Logical, if TRUE simplifies nested lists into vectors and data frames for JSON resources |
force_download |
Logical, force download if TRUE |
quiet_download |
logical, silent download |
... |
extra parameters |
an tibble
, a list
, a stars
or a sf
object depending
on the type of resource you are reading from HDX
Manage cached HDX downloaded files
rhdx_cache_set_dir(path) rhdx_cache_get_dir() rhdx_cache_list() rhdx_cache_delete(file) rhdx_cache_clear()
rhdx_cache_set_dir(path) rhdx_cache_get_dir() rhdx_cache_list() rhdx_cache_delete(file) rhdx_cache_clear()
path |
Character directory to set |
file |
Character, the file to delete |
The default cache directory is
~/.cache/R/rhdx_cache
, but you can set
your own path using rhdx_cache_set_dir()
the cache directory
the cache directory
list of files in the cache
## Not run: rhdx_cache ## change the default cache directory tmp <- tempdir() rhdx_cache_set_dir(tmp) ## print current cache directory rhdx_cache_get_dir() ## List available files in the current cache directory rhdx_cache_list() l <- rhdx_cache_list()[1] ## get the first file rhdx_cache_delete(l) ## delete it rhdx_cache_clear() ## delete all cached files ## End(Not run)
## Not run: rhdx_cache ## change the default cache directory tmp <- tempdir() rhdx_cache_set_dir(tmp) ## print current cache directory rhdx_cache_get_dir() ## List available files in the current cache directory rhdx_cache_list() l <- rhdx_cache_list()[1] ## get the first file rhdx_cache_delete(l) ## delete it rhdx_cache_clear() ## delete all cached files ## End(Not run)
Search for datasets on HDX
search_datasets( query = "*:*", filter_query = NULL, rows = 10L, start = 0L, page_size = 1000L, configuration = NULL, ... )
search_datasets( query = "*:*", filter_query = NULL, rows = 10L, start = 0L, page_size = 1000L, configuration = NULL, ... )
query |
Character Query terms, use solr format and default to ":" (match everything) |
filter_query |
Character Filter Query results |
rows |
integer; Number of matching records to return. Defaults to 10. |
start |
integer; the offset in the complete result for where the set of returned datasets should begin. |
page_size |
integer; Size of page to return. Defaults to 1000. |
configuration |
Configuration object. |
... |
Extra parameters for |
Search and find datasets on HDX
A list of HDX datasets
## Not run: # Setting the config to use HDX default server search_datasets("displaced nigeria", rows = 3L) ## End(Not run)
## Not run: # Setting the config to use HDX default server search_datasets("displaced nigeria", rows = 3L) ## End(Not run)
Search Resources
search_resources(query = "*:*", configuration = NULL, ...)
search_resources(query = "*:*", configuration = NULL, ...)
query |
Character, a query |
configuration |
a Configuration object |
... |
extra params |
Search for datasets on HDX
search_tags( query = "", vocabulary_id = NULL, limit = NULL, offset = NULL, configuration = NULL )
search_tags( query = "", vocabulary_id = NULL, limit = NULL, offset = NULL, configuration = NULL )
query |
(character) - character to search for |
vocabulary_id |
(character) - the id or name of the tag vocabulary to search in |
limit |
(integer) - the maximum number of tags to return |
offset |
(integer) - when |
configuration |
Configuration object. |
Search and find tags on HDX
A list of HDX tags
## Not run: # Setting the config to use HDX default server search_tags("idps", rows = 3L) ## End(Not run)
## Not run: # Setting the config to use HDX default server search_tags("idps", rows = 3L) ## End(Not run)
Sets the configuration settings for using rhdx.
set_rhdx_config( hdx_site = "prod", hdx_key = NULL, read_only = TRUE, hdx_config = NULL, hdx_config_file = NULL, configuration = NULL ) get_rhdx_config()
set_rhdx_config( hdx_site = "prod", hdx_key = NULL, read_only = TRUE, hdx_config = NULL, hdx_config_file = NULL, configuration = NULL ) get_rhdx_config()
hdx_site |
Character to specify which HDX server you want to use. Default to "prod". |
hdx_key |
Character for the CKAN API key, it is required to push data into HDX |
read_only |
Logical if |
hdx_config |
List of HDX configuration |
hdx_config_file |
Character, path of the HDX config file in JSON and YAML format |
configuration |
Configuration object. |
Setting up a configuration will help you access from an HDX server
Invisibly returns the rhdx config object
## Not run: # Setting the config to use HDX default server set_rhdx_config(hdx_site = "demo") # You can check your configuration using \code{get_rhdx_config} config <- get_rhdx_config() config ## End(Not run)
## Not run: # Setting the config to use HDX default server set_rhdx_config(hdx_site = "demo") # You can check your configuration using \code{get_rhdx_config} config <- get_rhdx_config() config ## End(Not run)
HDX Tag
HDX Tag
HDX tag
rhdx::HDXObject
-> Tag
data
list of tag field element
new()
Create a new Tag object
Tag$new(initial_data = NULL, configuration = NULL)
initial_data
list data with required fields to create a tag object
configuration
Configuration configuration to use
a Tag object
as_list()
Tag object to list
Tag$as_list()
a list with of tag fields element
print()
Print a Tag object
Tag$print()
clone()
The objects of this class are cloneable with this method.
Tag$clone(deep = FALSE)
deep
Whether to make a deep clone.
HDX Vocabulary
HDX Vocabulary
HDX Vocabulary
rhdx::HDXObject
-> Vocabulary
data
list of tag field element
new()
Create a new Tag object
Vocabulary$new(initial_data = NULL, configuration = NULL)
initial_data
list data with required fields to create a tag object
configuration
Configuration configuration to use
a Tag object
as_list()
Tag object to list
Vocabulary$as_list()
a list with of tag fields element
authorized_tags_name()
List of accepted tags on HDX
Vocabulary$authorized_tags_name()
a vector of tags name
print()
Print a Vocabulary object
Vocabulary$print()
clone()
The objects of this class are cloneable with this method.
Vocabulary$clone(deep = FALSE)
deep
Whether to make a deep clone.