Commit cbda14f5 authored by Pauline Maury Laribière's avatar Pauline Maury Laribière
Browse files

all check pass

parent bd7affcc
Pipeline #270125 passed with stage
in 21 seconds
###############################################################
########################## i14y APIs ##########################
###############################################################
#' Get a codelist based on an identifier
#'
#' @param identifier the codelist's identifier
......@@ -13,9 +9,6 @@
#'
#' @return response based on the export format
#' @export
#'
#' @examples
#' get_codelist(identifier='CL_NOGA_SECTION')
get_codelist <- function(identifier,
export_format = "SDMX-ML",
version_format = 2.1,
......@@ -38,9 +31,6 @@ get_codelist <- function(identifier,
#'
#' @return data structure
#' @export
#'
#' @examples
#' get_data_structure(identifier='HCL_NOGA', language='it')
get_data_structure <- function(identifier, language = "en") {
api <- api_class(
api_type = "dcat_data_structure",
......@@ -63,9 +53,6 @@ get_data_structure <- function(identifier, language = "en") {
#' @return dataframe with 3 columns
#' (Code, Parent and Name in the selected language)
#' @export
#'
#' @examples
#' get_nomenclature_one_level(identifier='HCL_CH_ISCO_19_PROF', filters=my_filters, level_number=2)
get_nomenclature_one_level <- function(identifier,
filters,
level_number = 1,
......@@ -96,10 +83,6 @@ get_nomenclature_one_level <- function(identifier,
#' @return dataframe columns
#' from `level_from` to `level_to` codes
#' @export
#'
#' @examples
#' get_nomenclature_multiple_levels(identifier='HCL_CH_ISCO_19_PROF',
#' filters=my_filters, level_from=2, level_to=5)
get_nomenclature_multiple_levels <- function(identifier,
filters,
level_from = 1,
......@@ -114,17 +97,4 @@ get_nomenclature_multiple_levels <- function(identifier,
export_format = "CSV"
)
res <- api$get_response()
# Post-processing
# fill sub groups rows with parent group's values (instead of NA)
nb_col <- level_to - level_from + 1
group_columns <- names(res)[1:nb_col]
res[[group_columns[[1]]]] <- data.table::nafill(res[[group_columns[[1]]]], type="locf")
res[group_columns[2:(level_to - level_from + 1)]] <- res %>%
group_by(group_columns[1]) %>%
subset(select=group_columns[2:(level_to - level_from + 1)]) %>%
data.table::nafill(type="locf")
res
}
......@@ -14,10 +14,6 @@
#' @field api_url character. The url to make the request to.
#'
#' @importFrom methods new
#'
#' @examples
#' api <- api_class(api_type = "codelist", id = "CL_NOGA_SECTION")
#' api <- api_class(api_type = "content_configuration")
api_class <- setRefClass(
"Api",
fields = list(
......
......@@ -36,13 +36,12 @@ REQUEST_FUNCTION_MAPPING <- hash::hash(
#' Transform a hash object into a string of parameters
#' hash::hash("a" = list("1"), "b" = list("2", "3"))
#' becomes "a=1&b=2&b=3"
#'
#' @param filters hash object
#'
#' @return formatted string of parameters
#' @examples
#' filters <- hash::hash("a" = list("1"), "b" = list("2", "3"))
#' hash_to_string(filters) -> "a=1&b=2&b=3"
hash_to_string <- function(filters) {
string <- ""
for (prop in ls(filters)) {
......
......@@ -31,7 +31,3 @@ Available are 'fr', 'de', 'it', 'en'}
}}
\examples{
api <- api_class(api_type = "codelist", id = "CL_NOGA_SECTION")
api <- api_class(api_type = "content_configuration")
}
......@@ -28,6 +28,3 @@ response based on the export format
\description{
Get a codelist based on an identifier
}
\examples{
get_codelist(identifier='CL_NOGA_SECTION')
}
......@@ -18,6 +18,3 @@ data structure
\description{
Get the data structure
}
\examples{
get_data_structure(identifier='HCL_NOGA', language='it')
}
......@@ -34,7 +34,3 @@ from `level_from` to `level_to` codes
\description{
Get multiple levels of a nomenclature (from `level_from` to `level_to`)
}
\examples{
get_nomenclature_multiple_levels(identifier='HCL_CH_ISCO_19_PROF',
filters=my_filters, level_from=2, level_to=5)
}
......@@ -31,6 +31,3 @@ dataframe with 3 columns
\description{
Get one level of a nomenclature
}
\examples{
get_nomenclature_one_level(identifier='HCL_CH_ISCO_19_PROF', filters=my_filters, level_number=2)
}
......@@ -2,7 +2,9 @@
% Please edit documentation in R/format_request.R
\name{hash_to_string}
\alias{hash_to_string}
\title{Transform a hash object into a string of parameters}
\title{Transform a hash object into a string of parameters
hash::hash("a" = list("1"), "b" = list("2", "3"))
becomes "a=1&b=2&b=3"}
\usage{
hash_to_string(filters)
}
......@@ -14,8 +16,6 @@ formatted string of parameters
}
\description{
Transform a hash object into a string of parameters
}
\examples{
filters <- hash::hash("a" = list("1"), "b" = list("2", "3"))
hash_to_string(filters) -> "a=1&b=2&b=3"
hash::hash("a" = list("1"), "b" = list("2", "3"))
becomes "a=1&b=2&b=3"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment