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

before removal of many functions

parent e7377d29
Pipeline #270113 failed with stage
in 1 minute and 24 seconds
Package: fso_metadata
Type: Package
Title: Metadata Auto R
Version: 0.0.0.1
Authors@R: person("Pauline", "Maury Laribiere", email = "pauline.maury-laribiere@bfs.admin.ch", role = c("aut", "cre"))
Depends: R (>= 3.1.0)
License: What license is it under?
LazyData: true
Imports:
dplyr,
glue,
hash,
httr,
jsonlite
RoxygenNote: 7.1.1
identifier <- 'HCL_CH_ISCO_19_PROF'
language <- 'fr'
level_from <- 1
level_to <- 4
annotations <- FALSE
my_filters <- hash::hash('prop1'= list("string"))
parameters <- glue::glue("language={language}&levelFrom={level_from}&levelTo={level_to}&annotations={tolower(annotations)}&{hash_to_string(my_filters)}")
print(parameters)
api <- api_class(
api_type = "nomenclature_multiple_levels",
id = identifier,
parameters = parameters,
export_format = "CSV"
)
res <- api$get_response()
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[(level_from + 1):level_to]] <- res %>%
group_by(group_columns[[level_from]]) %>%
subset(select=group_columns[(level_from + 1):level_to]) %>%
data.table::nafill(type="locf")
str(res)
......@@ -10,3 +10,7 @@ library(httr)
library(jsonlite)
library(rsdmx)
pkgload::load_all()
devtools::check('my_package')
devtools::document()
Package: fso.metadata
Type: Package
Title: Metadata Auto R
Version: 0.0.1
Date: 2021-22-10
Authors@R: person("Pauline", "Maury Laribiere", email = "pauline.maury-laribiere@bfs.admin.ch", role = c("aut", "cre"))
Author: Pauline Maury Laribiere [aut, cre],
Maintainer: Pauline Maury Laribiere <pauline.maury-laribiere@bfs.admin.ch>
Description: This package aims to simplify the access to the Swiss Federal Statistical Office metadata. Following the implementation in the interoperability platform and the SIS portal, the APIs are made available here in R. This public library is made available for the internal FSO staff, the federal administration and for external actors.
Depends: R (>= 3.1.0)
License: GPL (>= 2)
Encoding: UTF-8
URL: https://renkulab.io/gitlab/pauline.maury-laribiere/metadata-auto-r-library
LazyData: true
Imports:
data.table,
dplyr,
glue,
hash,
httr,
jsonlite,
methods,
rsdmx
RoxygenNote: 7.1.1
......@@ -19,3 +19,5 @@ export(get_nomenclature_multiple_levels)
export(get_nomenclature_one_level)
export(get_nomenclature_path_nodes)
export(query_nomenclature)
importFrom(methods,new)
importFrom(utils,read.csv)
......@@ -142,7 +142,8 @@ get_data_structure <- function(identifier, language = "en") {
#' @export
#'
#' @examples
#' get_nomenclature_path_nodes(identifier='HCL_CH_ISCO_19_PROF', path='.', filters=my_filters)
#' get_nomenclature_path_nodes(identifier='HCL_CH_ISCO_19_PROF', path='.',
#' filters=my_filters)
get_nomenclature_path_nodes <- function(identifier,
path = ".",
filters = "",
......@@ -203,9 +204,10 @@ 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(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,
......@@ -250,7 +252,8 @@ get_nomenclature_multiple_levels <- function(identifier,
#' @export
#'
#' @examples
#' query_nomenclature(identifier='HCL_CH_ISCO_19_PROF', query='SELECT *', page_number=5, page_size=2, filters=my_filters)
#' query_nomenclature(identifier='HCL_CH_ISCO_19_PROF', query='SELECT *',
#' page_number=5, page_size=2, filters=my_filters)
query_nomenclature <- function(identifier,
query,
page_number,
......
......@@ -15,6 +15,8 @@
#' @field path character. The path leading to the nodes
#' (for 'nomenclature_search')
#' @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")
......
......@@ -20,6 +20,7 @@ json_request <- function(url) {
#' API query for CSV output
#'
#' @param url url to query
#' @importFrom utils read.csv
#'
#' @return dataframe response
csv_request <- function(url) {
......
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