From 7fefe089a0284f225765713d04bb76bc22b8be73 Mon Sep 17 00:00:00 2001 From: "long.nguyen" Date: Sun, 25 Jun 2023 22:56:26 +0200 Subject: [PATCH 1/8] CRAN release --- .Rbuildignore | 2 ++ CRAN-SUBMISSION | 3 +++ DESCRIPTION | 6 +++++- NEWS.md | 3 +++ R/data.R | 2 +- R/gen_alternative_terms.R | 2 +- R/gen_auth.R | 4 ++++ R/gen_cube.R | 3 +++ R/gen_table.R | 2 ++ cran-comments.md | 5 +++++ man/evas_list_long_20220724.Rd | 2 +- man/gen_alternative_terms.Rd | 2 +- man/gen_auth_save.Rd | 3 +++ man/gen_cube.Rd | 4 ++++ man/gen_table.Rd | 3 +++ 15 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 CRAN-SUBMISSION create mode 100644 NEWS.md create mode 100644 cran-comments.md diff --git a/.Rbuildignore b/.Rbuildignore index e79efb0..5148e68 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,3 +9,5 @@ ^docs$ ^pkgdown$ ^codecov\.yml$ +^cran-comments\.md$ +^CRAN-SUBMISSION$ diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION new file mode 100644 index 0000000..081ce5a --- /dev/null +++ b/CRAN-SUBMISSION @@ -0,0 +1,3 @@ +Version: 0.1.0 +Date: 2023-06-25 21:06:13 UTC +SHA: dd904701d8e2e3f9a435484b2a84f30b0ad8b889 diff --git a/DESCRIPTION b/DESCRIPTION index b61e471..1011298 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,13 +24,17 @@ Imports: httr2, memoise, readr, + stats, tibble, + tools, + utils, vctrs Suggests: httptest2, knitr, rmarkdown, - testthat (>= 3.0.0) + testthat (>= 3.0.0), + usethis VignetteBuilder: knitr Config/testthat/edition: 3 diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..3a2d50c --- /dev/null +++ b/NEWS.md @@ -0,0 +1,3 @@ +# restatis 0.1.0 + +* Initial CRAN submission. diff --git a/R/data.R b/R/data.R index 67095ce..02ea390 100644 --- a/R/data.R +++ b/R/data.R @@ -5,7 +5,7 @@ #' \describe{ #' \item{EVAS}{EVAS code} #' \item{Beschreibung}{Details on the EVAS code} -#' \item{Titel}{Alternative desription of EVAS code contents} +#' \item{Titel}{Alternative description of EVAS code contents} #' ... #' } #' @source diff --git a/R/gen_alternative_terms.R b/R/gen_alternative_terms.R index c54a547..576c773 100644 --- a/R/gen_alternative_terms.R +++ b/R/gen_alternative_terms.R @@ -1,4 +1,4 @@ -#' gen_alternative_terms: Call for similiar or spelling related terms for further search +#' gen_alternative_terms: Call for similar or spelling related terms for further search #' #' @description Function to find search terms that are similar or related to one another and also represented in Genesis. #' diff --git a/R/gen_auth.R b/R/gen_auth.R index c888b0f..34ed977 100644 --- a/R/gen_auth.R +++ b/R/gen_auth.R @@ -13,6 +13,8 @@ #' be added to .Renviron. The usethis package includes a helper function for #' editing .Renviron files from an R session with [usethis::edit_r_environ()]. #' +#' @return Path to the RDS file in which credentials are saved, invisibly. +#' #' @export gen_auth_save <- function() { @@ -44,6 +46,8 @@ gen_auth_save <- function() { path = auth_path, key = "RESTATIS_KEY" ) + + invisible(auth_path) } gen_auth_get <- function() { diff --git a/R/gen_cube.R b/R/gen_cube.R index e578057..89f91b6 100644 --- a/R/gen_cube.R +++ b/R/gen_cube.R @@ -36,6 +36,9 @@ #' descriptions in German (`"de"`) or English (`"en"`)?} #' } #' +#' @return A [tibble][tibble::tibble()]. Non-data contents of the data cube object are saved in +#' the `metadata` [attribute][base::attr()] of the data frame. +#' #' @export #' #' @examples diff --git a/R/gen_table.R b/R/gen_table.R index 8d1690a..67a7b37 100644 --- a/R/gen_table.R +++ b/R/gen_table.R @@ -34,6 +34,8 @@ #' descriptions in German (`"de"`) or English (`"en"`)?} #' } #' +#' @return A [tibble][tibble::tibble()]. +#' #' @export #' #' @examples diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..858617d --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,5 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. diff --git a/man/evas_list_long_20220724.Rd b/man/evas_list_long_20220724.Rd index b41de3e..fcf3a84 100644 --- a/man/evas_list_long_20220724.Rd +++ b/man/evas_list_long_20220724.Rd @@ -11,7 +11,7 @@ A data frame with 1,097 rows and 3 columns: \describe{ \item{EVAS}{EVAS code} \item{Beschreibung}{Details on the EVAS code} -\item{Titel}{Alternative desription of EVAS code contents} +\item{Titel}{Alternative description of EVAS code contents} ... } } diff --git a/man/gen_alternative_terms.Rd b/man/gen_alternative_terms.Rd index 3eb4d8e..9c62d18 100644 --- a/man/gen_alternative_terms.Rd +++ b/man/gen_alternative_terms.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_alternative_terms.R \name{gen_alternative_terms} \alias{gen_alternative_terms} -\title{gen_alternative_terms: Call for similiar or spelling related terms for further search} +\title{gen_alternative_terms: Call for similar or spelling related terms for further search} \usage{ gen_alternative_terms(term = NULL, similarity = TRUE, ...) } diff --git a/man/gen_auth_save.Rd b/man/gen_auth_save.Rd index e8ce643..96b3a04 100644 --- a/man/gen_auth_save.Rd +++ b/man/gen_auth_save.Rd @@ -6,6 +6,9 @@ \usage{ gen_auth_save() } +\value{ +Path to the RDS file in which credentials are saved, invisibly. +} \description{ See Details. } diff --git a/man/gen_cube.Rd b/man/gen_cube.Rd index 85a8314..7c1361e 100644 --- a/man/gen_cube.Rd +++ b/man/gen_cube.Rd @@ -42,6 +42,10 @@ updated after this #' date.} descriptions in German (\code{"de"}) or English (\code{"en"})?} }} } +\value{ +A \link[tibble:tibble]{tibble}. Non-data contents of the data cube object are saved in +the \code{metadata} \link[base:attr]{attribute} of the data frame. +} \description{ Download a cube with data from Genesis } diff --git a/man/gen_table.Rd b/man/gen_table.Rd index 5d4ac6f..dbb99ca 100644 --- a/man/gen_table.Rd +++ b/man/gen_table.Rd @@ -40,6 +40,9 @@ updated after this #' date.} descriptions in German (\code{"de"}) or English (\code{"en"})?} }} } +\value{ +A \link[tibble:tibble]{tibble}. +} \description{ Download a table with data from Genesis } From 00442bfbfaf36a60f9fb1049cfa17eb6f7352a2c Mon Sep 17 00:00:00 2001 From: "long.nguyen" Date: Sun, 25 Jun 2023 23:20:47 +0200 Subject: [PATCH 2/8] Add repo link --- .github/workflows/R-CMD-check.yaml | 4 ++-- .github/workflows/pkgdown.yaml | 4 ++-- .github/workflows/test-coverage.yaml | 4 ++-- DESCRIPTION | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 43b0a48..ca1f562 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -2,9 +2,9 @@ # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: [dev] + branches: [main, dev] pull_request: - branches: [dev] + branches: [main, dev] name: R-CMD-check diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 2aa6ce5..0286127 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -2,9 +2,9 @@ # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: [dev] + branches: [main, dev] pull_request: - branches: [dev] + branches: [main, dev] release: types: [published] workflow_dispatch: diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 436b1db..64de9f5 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -2,9 +2,9 @@ # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: [dev] + branches: [main, dev] pull_request: - branches: [dev] + branches: [main, dev] name: test-coverage diff --git a/DESCRIPTION b/DESCRIPTION index 1011298..6ef7322 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,7 +16,8 @@ Description: A RESTful API wrapper for accessing the GENESIS database of search functions, credential management, result caching, and handling remote background jobs for large datasets. License: MIT + file LICENSE -URL: https://correlaid.github.io/restatis/ +URL: https://correlaid.github.io/restatis/, https://github.com/CorrelAid/restatis +BugReports: https://github.com/CorrelAid/restatis/issues Depends: R (>= 2.10) Imports: From 63870363223f4b199ebb8c56751e62974050d69e Mon Sep 17 00:00:00 2001 From: "long.nguyen" Date: Mon, 26 Jun 2023 14:56:15 +0200 Subject: [PATCH 3/8] Reformat R scripts --- R/gen_alternative_terms.R | 34 +- R/gen_auth.R | 3 - R/gen_catalogue.R | 256 ++++---- R/gen_cube.R | 53 +- R/gen_find.R | 1309 +++++++++++++++++++------------------ R/gen_list_jobs.R | 15 +- R/gen_meta_data.R | 408 ++++++------ R/gen_modified_data.R | 85 +-- R/gen_objects2stat.R | 208 +++--- R/gen_objects2var.R | 206 +++--- R/gen_table.R | 8 +- R/gen_var2-val2.R | 191 +++--- R/utils.R | 28 +- 13 files changed, 1365 insertions(+), 1439 deletions(-) diff --git a/R/gen_alternative_terms.R b/R/gen_alternative_terms.R index 576c773..e6b563e 100644 --- a/R/gen_alternative_terms.R +++ b/R/gen_alternative_terms.R @@ -22,58 +22,48 @@ gen_alternative_terms <- function(term = NULL, similarity = TRUE, ...) { - caller <- as.character(match.call()[1]) - check_function_input(term = term, - similarity = similarity, - caller = caller) + check_function_input( + term = term, + similarity = similarity, + caller = caller + ) -#------------------------------------------------------------------------------- + #------------------------------------------------------------------------------- results_raw <- gen_api("catalogue/terms", - - username = gen_auth_get()$username, - password = gen_auth_get()$password, selection = term, - ...) + ... + ) results_json <- test_if_json(results_raw) if (length(results_json$List) == 0) { - stop("No related terms found for your code.", call. = FALSE) - } else { - # similarity von Woertern berechnen und nach diesen Ordnen? termslist <- c() termslist <- lapply(results_json$List, function(x) { - append(termslist, x$Content) - }) termslist <- lapply(termslist, function(x) { - gsub("\\s+", " ", x) - }) termslist <- unlist(termslist) if (isTRUE(similarity)) { - # generalized levenstein edit distance termslist <- termslist[order(utils::adist(term, - termslist, - ignore.case = TRUE))] + termslist, + ignore.case = TRUE + ))] } else { - # nchar order termslist <- termslist[order(unlist(lapply(termslist, nchar)))] - } list_resp <- list("Output" = termslist) @@ -84,7 +74,5 @@ gen_alternative_terms <- function(term = NULL, attr(list_resp, "Copyright") <- results_json$Copyright return(list_resp) - } - } diff --git a/R/gen_auth.R b/R/gen_auth.R index 34ed977..fff9ff7 100644 --- a/R/gen_auth.R +++ b/R/gen_auth.R @@ -17,7 +17,6 @@ #' #' @export gen_auth_save <- function() { - username <- gen_auth_ask("username") password <- gen_auth_ask("password") @@ -51,7 +50,6 @@ gen_auth_save <- function() { } gen_auth_get <- function() { - auth_path <- gen_auth_path("auth.rds") if (!(file.exists(auth_path) && nzchar(Sys.getenv("RESTATIS_KEY")))) { @@ -78,4 +76,3 @@ gen_auth_ask <- function(credential_type) { gen_auth_path <- function(...) { file.path(tools::R_user_dir("restatis", "config"), ...) } - diff --git a/R/gen_catalogue.R b/R/gen_catalogue.R index d408533..cc3557d 100644 --- a/R/gen_catalogue.R +++ b/R/gen_catalogue.R @@ -30,15 +30,16 @@ gen_catalogue <- function(code = NULL, sortcriterion = c("code", "content"), error.ignore = FALSE, ...) { - caller <- as.character(match.call()[1]) - check_function_input(code = code, - category = category, - detailed = detailed, - sortcriterion = sortcriterion, - error.ignore = error.ignore, - caller = caller) + check_function_input( + code = code, + category = category, + detailed = detailed, + sortcriterion = sortcriterion, + error.ignore = error.ignore, + caller = caller + ) sortcriterion <- match.arg(sortcriterion) @@ -46,51 +47,43 @@ gen_catalogue <- function(code = NULL, # Processing #### if ("cubes" %in% category) { - results_raw <- gen_api("catalogue/cubes", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - selection = code, - ...) + selection = code, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { list_of_cubes <- "No 'cubes' object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { list_of_cubes <- results_json$Status$Content - - } else if(empty_object == "DONE"){ - - if (isTRUE(detailed)) { - - list_of_cubes <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Time", - "LatestUpdate", - "State", - "Information")) - - } else { - - list_of_cubes <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content")) - - - - } - - list_of_cubes$Object_Type <- "Cube" - - list_of_cubes <- tibble::as_tibble(list_of_cubes) - + } else if (empty_object == "DONE") { + if (isTRUE(detailed)) { + list_of_cubes <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Time", + "LatestUpdate", + "State", + "Information" + ) + ) + } else { + list_of_cubes <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content" + ) + ) + } + + list_of_cubes$Object_Type <- "Cube" + + list_of_cubes <- tibble::as_tibble(list_of_cubes) } } @@ -98,51 +91,42 @@ gen_catalogue <- function(code = NULL, #----------------------------------------------------------------------------- if ("statistics" %in% category) { - results_raw <- gen_api("catalogue/statistics", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - selection = code, - sortcriterion = sortcriterion, - ...) + selection = code, + sortcriterion = sortcriterion, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { list_of.stats <- "No 'statistics' object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { list_of.stats <- results_json$Status$Content - - } else if(empty_object == "DONE"){ - - if (isTRUE(detailed)) { - - list_of.stats <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Cubes", - "Information")) - - - } else { - - list_of.stats <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content")) - - - - } - - list_of.stats$Object_Type <- "Statistic" - - list_of.stats <- tibble::as_tibble(list_of.stats) - + } else if (empty_object == "DONE") { + if (isTRUE(detailed)) { + list_of.stats <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Cubes", + "Information" + ) + ) + } else { + list_of.stats <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content" + ) + ) + } + + list_of.stats$Object_Type <- "Statistic" + + list_of.stats <- tibble::as_tibble(list_of.stats) } } @@ -151,50 +135,41 @@ gen_catalogue <- function(code = NULL, #----------------------------------------------------------------------------- if ("tables" %in% category) { - results_raw <- gen_api("catalogue/tables", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - selection = code, - sortcriterion = sortcriterion, - ...) + selection = code, + sortcriterion = sortcriterion, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { list_of.tabs <- "No 'tables' object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { list_of.tabs <- results_json$Status$Content - - } else if(empty_object == "DONE"){ - - if (isTRUE(detailed)) { - - list_of.tabs <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Time")) - - - - } else { - - list_of.tabs <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content")) - - - } - - list_of.tabs$Object_Type <- "Table" - - list_of.tabs <- tibble::as_tibble(list_of.tabs) - + } else if (empty_object == "DONE") { + if (isTRUE(detailed)) { + list_of.tabs <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Time" + ) + ) + } else { + list_of.tabs <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content" + ) + ) + } + + list_of.tabs$Object_Type <- "Table" + + list_of.tabs <- tibble::as_tibble(list_of.tabs) } } @@ -203,49 +178,41 @@ gen_catalogue <- function(code = NULL, # Summary #### if (all(c("tables", "statistics", "cubes") %in% category)) { - list_resp <- list( - "Cubes" = if(length(list_of_cubes) == 1){list_of_cubes} else {list("A" = forming_evas(list_of_cubes))}, - "Statistics" = if(length(list_of.stats) == 1){list_of.stats} else {list("B" = forming_evas(list_of.stats))}, - "Tables" = if(length(list_of.tabs) == 1){list_of.tabs} else {list("C" = forming_evas(list_of.tabs))} - ) - + "Cubes" = if (length(list_of_cubes) == 1) { + list_of_cubes + } else { + list("A" = forming_evas(list_of_cubes)) + }, + "Statistics" = if (length(list_of.stats) == 1) { + list_of.stats + } else { + list("B" = forming_evas(list_of.stats)) + }, + "Tables" = if (length(list_of.tabs) == 1) { + list_of.tabs + } else { + list("C" = forming_evas(list_of.tabs)) + } + ) } else if (category == "cubes") { - - if(length(list_of_cubes) == 1){ - + if (length(list_of_cubes) == 1) { list_resp <- list("Output" = list_of_cubes) - } else { - list_resp <- list("Output" = forming_evas(list_of_cubes)) - } - } else if (category == "statistics") { - - if(length(list_of.stats) == 1){ - + if (length(list_of.stats) == 1) { list_resp <- list("Output" = list_of.stats) - } else { - list_resp <- list("Output" = forming_evas(list_of.stats)) - } - } else if (category == "tables") { - - if(length(list_of.tabs) == 1){ - + if (length(list_of.tabs) == 1) { list_resp <- list("Output" = list_of.tabs) - } else { - list_resp <- list("Output" = forming_evas(list_of.tabs)) - } - } attr(list_resp, "Code") <- results_json$Parameter$selection @@ -255,5 +222,4 @@ gen_catalogue <- function(code = NULL, attr(list_resp, "Copyright") <- results_json$Copyright return(list_resp) - } diff --git a/R/gen_cube.R b/R/gen_cube.R index 89f91b6..84f5b02 100644 --- a/R/gen_cube.R +++ b/R/gen_cube.R @@ -47,9 +47,7 @@ #' } #' gen_cube <- function(name, ...) { - gen_cube_(name, ...) - } #------------------------------------------------------------------------------- @@ -73,11 +71,13 @@ gen_cube_ <- function(name, classifyingkey3 = NULL, stand = NULL, language = Sys.getenv("GENESIS_LANG")) { - area <- match.arg(area) if (!isTRUE(language == "en")) { - area <- switch(area, public = "\u00F6ffentlich", user = "benutzer") + area <- switch(area, + public = "\u00F6ffentlich", + user = "benutzer" + ) } param_check_year(startyear) @@ -89,28 +89,29 @@ gen_cube_ <- function(name, classifyingkey2 <- param_collapse_vec(classifyingkey2) classifyingkey3 <- param_collapse_vec(classifyingkey3) - cube <- gen_api("data/cubefile", name = name, - name = name, - area = area, - values = values, - metadata = metadata, - additionals = additionals, - startyear = startyear, - endyear = endyear, - timeslices = timeslices, - contents = contents, - regionalvariable = regionalvariable, - regionalkey = regionalkey, - classifyingvariable1 = classifyingvariable1, - classifyingkey1 = classifyingkey1, - classifyingvariable2 = classifyingvariable2, - classifyingkey2 = classifyingkey2, - classifyingvariable3 = classifyingvariable3, - classifyingkey3 = classifyingkey3, - stand = stand, - language = language, - job = FALSE) %>% - + cube <- gen_api("data/cubefile", + name = name, + name = name, + area = area, + values = values, + metadata = metadata, + additionals = additionals, + startyear = startyear, + endyear = endyear, + timeslices = timeslices, + contents = contents, + regionalvariable = regionalvariable, + regionalkey = regionalkey, + classifyingvariable1 = classifyingvariable1, + classifyingkey1 = classifyingkey1, + classifyingvariable2 = classifyingvariable2, + classifyingkey2 = classifyingkey2, + classifyingvariable3 = classifyingvariable3, + classifyingkey3 = classifyingkey3, + stand = stand, + language = language, + job = FALSE + ) %>% read_cube() %>% rename_cube_data_columns() diff --git a/R/gen_find.R b/R/gen_find.R index ef8b9c2..596d4cc 100644 --- a/R/gen_find.R +++ b/R/gen_find.R @@ -35,26 +35,26 @@ gen_find <- function(term = NULL, ordering = TRUE, error.ignore = FALSE, ...) { - caller <- as.character(match.call()[1]) - check_function_input(term = term, - category = category, - detailed = detailed, - ordering = ordering, - error.ignore = error.ignore, - caller = caller) + check_function_input( + term = term, + category = category, + detailed = detailed, + ordering = ordering, + error.ignore = error.ignore, + caller = caller + ) category <- match.arg(category) #----------------------------------------------------------------------------- results_raw <- gen_api("find/find", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - term = term, - category = category, - ...) + term = term, + category = category, + ... + ) results_json <- test_if_json(results_raw) @@ -64,8 +64,7 @@ gen_find <- function(term = NULL, #----------------------------------------------------------------------------- - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { list_resp <- list("Output" = "No object found for your request.") attr(list_resp, "Term") <- results_json$Parameter$term @@ -74,9 +73,7 @@ gen_find <- function(term = NULL, attr(list_resp, "Copyright") <- results_json$Copyright return(list_resp) - - } else if (isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { list_resp <- list("Output" = results_json$Status$Content) attr(list_resp, "Term") <- results_json$Parameter$term @@ -85,695 +82,754 @@ gen_find <- function(term = NULL, attr(list_resp, "Copyright") <- results_json$Copyright return(list_resp) - } else if (empty_object == "DONE") { + if (detailed == TRUE) { + #----------------------------------------------------------------------------- - if (detailed == TRUE) { - - #----------------------------------------------------------------------------- - - if (category == "all") { - - df_table <- binding_lapply(results_json$Tables, - characteristics = c("Code", - "Content", - "Time")) - - df_table$Spezifisch <- ggsub(df_table) - - df_table$Variablen <- spezifisch_create(df_table) - - df_table$Object_Type <- "Table" - - #------------------------------------------------------------------------- - - df_stats <- binding_lapply(results_json$Statistics, - characteristics = c("Code", - "Content", - "Information", - "Cubes")) - - df_stats$Spezifisch <- ggsub(df_stats) - - df_stats$Variablen <- spezifisch_create(df_stats) - - df_stats$Object_Type <- "Statistic" - - #------------------------------------------------------------------------- - - df_variables <- binding_lapply(results_json$Variables, - characteristics = c("Code", - "Content", - "Type", - "Values", - "Information")) - - df_variables$Spezifisch <- ggsub(df_variables) - - df_variables$Variablen <- spezifisch_create(df_variables) - - df_variables$Object_Type <- "Variable" - - #------------------------------------------------------------------------- - - df_cubes <- binding_lapply(results_json$Cubes, - characteristics = c("Code", - "Content", - "Time", - "LatestUpdate", - "State", - "Information")) - - df_cubes$Spezifisch <- ggsub(df_cubes) - - df_cubes$Variablen <- spezifisch_create(df_cubes) - - df_cubes$Object_Type <- "Cube" - - #------------------------------------------------------------------------- - - if (nrow(df_table) != 0) { - df_table$Titel <- titel_search(df_table, term) - } - - if (nrow(df_stats) != 0) { - df_stats$Titel <- titel_search(df_stats, term) - } - - if (nrow(df_variables) != 0) { - df_variables$Titel <- titel_search(df_variables, term) - } - - if (nrow(df_cubes) != 0) { - df_cubes$Titel <- titel_search(df_cubes, term) - } - - #------------------------------------------------------------------------- - - if(isTRUE(ordering)) { - - df_table <- df_table[with(df_table, order(-Titel, -Variablen)), c("Code", - "Content", - "Titel", - "Time", - "Variablen", - "Spezifisch", - "Object_Type")] - - df_stats <- df_stats[with(df_stats, order(-Titel, -Variablen)), c( "Code", - "Content", - "Titel", - "Information", - "Cubes", - "Variablen", - "Spezifisch", - "Object_Type")] - - df_variables <- df_variables[with(df_variables, order(-Titel, -Variablen)), c( "Code", - "Content", - "Titel", - "Values", - "Information", - "Variablen", - "Spezifisch", - "Object_Type")] - - df_cubes <- df_cubes[with(df_cubes, order(-Titel, -Variablen)), c( "Code", - "Content", - "Titel", - "Time", - "LatestUpdate", - "State", - "Information", - "Variablen", - "Spezifisch", - "Object_Type")] - - } else { - - df_table <- df_table[, c("Code", - "Content", - "Titel", - "Time", - "Variablen", - "Spezifisch", - "Object_Type")] - - df_stats <- df_stats[, c("Code", - "Content", - "Titel", - "Information", - "Cubes", - "Variablen", - "Spezifisch", - "Object_Type")] - - df_variables <- df_variables[, c("Code", - "Content", - "Titel", - "Values", - "Information", - "Variablen", - "Spezifisch", - "Object_Type")] - - df_cubes <- df_cubes[, c("Code", - "Content", - "Titel", - "Time", - "LatestUpdate", - "State", - "Information", - "Variablen", - "Spezifisch", - "Object_Type")] - - } - - #------------------------------------------------------------------------- - - list_resp <- list("Tables" = tibble::as_tibble(df_table), - "Statistics" = tibble::as_tibble(df_stats), - "Variables" = tibble::as_tibble(df_variables), - "Cubes" = tibble::as_tibble(df_cubes)) - - attr(list_resp, "Term") <- results_json$Parameter$term - attr(list_resp, "Language") <- results_json$Parameter$language - attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength - attr(list_resp, "Copyright") <- results_json$Copyright - - return(list_resp) - - } - - if (category == "tables") { - - df_table <- binding_lapply(results_json$Tables, - characteristics = c("Code", - "Content", - "Time")) + if (category == "all") { + df_table <- binding_lapply(results_json$Tables, + characteristics = c( + "Code", + "Content", + "Time" + ) + ) + + df_table$Spezifisch <- ggsub(df_table) - df_table$Spezifisch <- ggsub(df_table) - - df_table$Variablen <- spezifisch_create(df_table) - - df_table$Object_Type <- "Table" - - #------------------------------------------------------------------------- - - if (nrow(df_table) != 0) { - df_table$Titel <- titel_search(df_table, term) - } - - if (isTRUE(ordering)) { - - df_table <- df_table[with(df_table, order(-Titel, -Variablen)), c("Code", - "Content", - "Titel", - "Time", - "Variablen", - "Spezifisch", - "Object_Type")] - - } else { - - df_table <- df_table[, c("Code", - "Content", - "Titel", - "Time", - "Variablen", - "Spezifisch", - "Object_Type")] - } - - #------------------------------------------------------------------------- - - list_resp <- list("Tables" = tibble::as_tibble(df_table)) - - attr(list_resp, "Term") <- results_json$Parameter$term - attr(list_resp, "Language") <- results_json$Parameter$language - attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength - attr(list_resp, "Copyright") <- results_json$Copyright - - return(list_resp) - - } - - #--------------------------------------------------------------------------- - - if (category == "statistics") { - - df_stats <- binding_lapply(results_json$Statistics, - characteristics = c("Code", - "Content", - "Information", - "Cubes")) - - df_stats$Spezifisch <- ggsub(df_stats) - - df_stats$Variablen <- spezifisch_create(df_stats) - - df_stats$Object_Type <- "Statistic" - - #------------------------------------------------------------------------- - - if (nrow(df_stats) != 0) { - df_stats$Titel <- titel_search(df_stats, term) + df_table$Variablen <- spezifisch_create(df_table) + + df_table$Object_Type <- "Table" + + #------------------------------------------------------------------------- + + df_stats <- binding_lapply(results_json$Statistics, + characteristics = c( + "Code", + "Content", + "Information", + "Cubes" + ) + ) + + df_stats$Spezifisch <- ggsub(df_stats) + + df_stats$Variablen <- spezifisch_create(df_stats) + + df_stats$Object_Type <- "Statistic" + + #------------------------------------------------------------------------- + + df_variables <- binding_lapply(results_json$Variables, + characteristics = c( + "Code", + "Content", + "Type", + "Values", + "Information" + ) + ) + + df_variables$Spezifisch <- ggsub(df_variables) + + df_variables$Variablen <- spezifisch_create(df_variables) + + df_variables$Object_Type <- "Variable" + + #------------------------------------------------------------------------- + + df_cubes <- binding_lapply(results_json$Cubes, + characteristics = c( + "Code", + "Content", + "Time", + "LatestUpdate", + "State", + "Information" + ) + ) + + df_cubes$Spezifisch <- ggsub(df_cubes) + + df_cubes$Variablen <- spezifisch_create(df_cubes) + + df_cubes$Object_Type <- "Cube" + + #------------------------------------------------------------------------- + + if (nrow(df_table) != 0) { + df_table$Titel <- titel_search(df_table, term) + } + + if (nrow(df_stats) != 0) { + df_stats$Titel <- titel_search(df_stats, term) + } + + if (nrow(df_variables) != 0) { + df_variables$Titel <- titel_search(df_variables, term) + } + + if (nrow(df_cubes) != 0) { + df_cubes$Titel <- titel_search(df_cubes, term) + } + + #------------------------------------------------------------------------- + + if (isTRUE(ordering)) { + df_table <- df_table[with(df_table, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Titel", + "Time", + "Variablen", + "Spezifisch", + "Object_Type" + )] + + df_stats <- df_stats[with(df_stats, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Titel", + "Information", + "Cubes", + "Variablen", + "Spezifisch", + "Object_Type" + )] + + df_variables <- df_variables[with(df_variables, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Titel", + "Values", + "Information", + "Variablen", + "Spezifisch", + "Object_Type" + )] + + df_cubes <- df_cubes[with(df_cubes, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Titel", + "Time", + "LatestUpdate", + "State", + "Information", + "Variablen", + "Spezifisch", + "Object_Type" + )] + } else { + df_table <- df_table[, c( + "Code", + "Content", + "Titel", + "Time", + "Variablen", + "Spezifisch", + "Object_Type" + )] + + df_stats <- df_stats[, c( + "Code", + "Content", + "Titel", + "Information", + "Cubes", + "Variablen", + "Spezifisch", + "Object_Type" + )] + + df_variables <- df_variables[, c( + "Code", + "Content", + "Titel", + "Values", + "Information", + "Variablen", + "Spezifisch", + "Object_Type" + )] + + df_cubes <- df_cubes[, c( + "Code", + "Content", + "Titel", + "Time", + "LatestUpdate", + "State", + "Information", + "Variablen", + "Spezifisch", + "Object_Type" + )] + } + + #------------------------------------------------------------------------- + + list_resp <- list( + "Tables" = tibble::as_tibble(df_table), + "Statistics" = tibble::as_tibble(df_stats), + "Variables" = tibble::as_tibble(df_variables), + "Cubes" = tibble::as_tibble(df_cubes) + ) + + attr(list_resp, "Term") <- results_json$Parameter$term + attr(list_resp, "Language") <- results_json$Parameter$language + attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength + attr(list_resp, "Copyright") <- results_json$Copyright + + return(list_resp) } - if(isTRUE(ordering)) { - - df_stats <- df_stats[with(df_stats, order(-Titel, -Variablen)), c( "Code", - "Content", - "Titel", - "Information", - "Cubes", - "Variablen", - "Spezifisch", - "Object_Type")] - - } else { - - df_stats <- df_stats[, c("Code", - "Content", - "Titel", - "Information", - "Cubes", - "Variablen", - "Spezifisch", - "Object_Type")] - - } - - list_resp <- list("Statistics" = tibble::as_tibble(df_stats)) - - attr(list_resp, "Term") <- results_json$Parameter$term - attr(list_resp, "Language") <- results_json$Parameter$language - attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength - attr(list_resp, "Copyright") <- results_json$Copyright - - return(list_resp) - - } - - #--------------------------------------------------------------------------- - - if (category == "variables") { - - df_variables <- binding_lapply(results_json$Variables, - characteristics = c("Code", - "Content", - "Type", - "Values", - "Information")) - - df_variables$Spezifisch <- ggsub(df_variables) - - df_variables$Variablen <- spezifisch_create(df_variables) - - df_variables$Object_Type <- "Variable" - - #------------------------------------------------------------------------- - - if (nrow(df_variables) != 0) { - df_variables$Titel <- titel_search(df_variables, term) + if (category == "tables") { + df_table <- binding_lapply(results_json$Tables, + characteristics = c( + "Code", + "Content", + "Time" + ) + ) + + df_table$Spezifisch <- ggsub(df_table) + + df_table$Variablen <- spezifisch_create(df_table) + + df_table$Object_Type <- "Table" + + #------------------------------------------------------------------------- + + if (nrow(df_table) != 0) { + df_table$Titel <- titel_search(df_table, term) + } + + if (isTRUE(ordering)) { + df_table <- df_table[with(df_table, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Titel", + "Time", + "Variablen", + "Spezifisch", + "Object_Type" + )] + } else { + df_table <- df_table[, c( + "Code", + "Content", + "Titel", + "Time", + "Variablen", + "Spezifisch", + "Object_Type" + )] + } + + #------------------------------------------------------------------------- + + list_resp <- list("Tables" = tibble::as_tibble(df_table)) + + attr(list_resp, "Term") <- results_json$Parameter$term + attr(list_resp, "Language") <- results_json$Parameter$language + attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength + attr(list_resp, "Copyright") <- results_json$Copyright + + return(list_resp) } - if(isTRUE(ordering)) { - - df_variables <- df_variables[with(df_variables, order(-Titel, -Variablen)), c( "Code", - "Content", - "Titel", - "Values", - "Information", - "Variablen", - "Spezifisch", - "Object_Type")] - - } else { - - df_variables <- df_variables[, c("Code", - "Content", - "Titel", - "Values", - "Information", - "Variablen", - "Spezifisch", - "Object_Type")] - + #--------------------------------------------------------------------------- + + if (category == "statistics") { + df_stats <- binding_lapply(results_json$Statistics, + characteristics = c( + "Code", + "Content", + "Information", + "Cubes" + ) + ) + + df_stats$Spezifisch <- ggsub(df_stats) + + df_stats$Variablen <- spezifisch_create(df_stats) + + df_stats$Object_Type <- "Statistic" + + #------------------------------------------------------------------------- + + if (nrow(df_stats) != 0) { + df_stats$Titel <- titel_search(df_stats, term) + } + + if (isTRUE(ordering)) { + df_stats <- df_stats[with(df_stats, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Titel", + "Information", + "Cubes", + "Variablen", + "Spezifisch", + "Object_Type" + )] + } else { + df_stats <- df_stats[, c( + "Code", + "Content", + "Titel", + "Information", + "Cubes", + "Variablen", + "Spezifisch", + "Object_Type" + )] + } + + list_resp <- list("Statistics" = tibble::as_tibble(df_stats)) + + attr(list_resp, "Term") <- results_json$Parameter$term + attr(list_resp, "Language") <- results_json$Parameter$language + attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength + attr(list_resp, "Copyright") <- results_json$Copyright + + return(list_resp) } - #------------------------------------------------------------------------- - - list_resp <- list("Variables" = tibble::as_tibble(df_variables)) - - attr(list_resp, "Term") <- results_json$Parameter$term - attr(list_resp, "Language") <- results_json$Parameter$language - attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength - attr(list_resp, "Copyright") <- results_json$Copyright - - return(list_resp) - } - - #--------------------------------------------------------------------------- - - if (category == "cubes") { - - df_cubes <- binding_lapply(results_json$Cubes, - characteristics = c("Code", - "Content", - "Time", - "LatestUpdate", - "State", - "Information")) - - df_cubes$Spezifisch <- ggsub(df_cubes) - - df_cubes$Variablen <- spezifisch_create(df_cubes) - - df_cubes$Object_Type <- "Cube" - - #------------------------------------------------------------------------- - - if (nrow(df_cubes) != 0) { - df_cubes$Titel <- titel_search(df_cubes, term) + #--------------------------------------------------------------------------- + + if (category == "variables") { + df_variables <- binding_lapply(results_json$Variables, + characteristics = c( + "Code", + "Content", + "Type", + "Values", + "Information" + ) + ) + + df_variables$Spezifisch <- ggsub(df_variables) + + df_variables$Variablen <- spezifisch_create(df_variables) + + df_variables$Object_Type <- "Variable" + + #------------------------------------------------------------------------- + + if (nrow(df_variables) != 0) { + df_variables$Titel <- titel_search(df_variables, term) + } + + if (isTRUE(ordering)) { + df_variables <- df_variables[with(df_variables, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Titel", + "Values", + "Information", + "Variablen", + "Spezifisch", + "Object_Type" + )] + } else { + df_variables <- df_variables[, c( + "Code", + "Content", + "Titel", + "Values", + "Information", + "Variablen", + "Spezifisch", + "Object_Type" + )] + } + + #------------------------------------------------------------------------- + + list_resp <- list("Variables" = tibble::as_tibble(df_variables)) + + attr(list_resp, "Term") <- results_json$Parameter$term + attr(list_resp, "Language") <- results_json$Parameter$language + attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength + attr(list_resp, "Copyright") <- results_json$Copyright + + return(list_resp) } - if(isTRUE(ordering)) { - - df_cubes <- df_cubes[with(df_cubes, order(-Titel, -Variablen)), c( "Code", - "Content", - "Titel", - "Time", - "LatestUpdate", - "State", - "Information", - "Variablen", - "Spezifisch", - "Object_Type")] - - } else { - - df_cubes <- df_cubes[, c("Code", - "Content", - "Titel", - "Time", - "LatestUpdate", - "State", - "Information", - "Variablen", - "Spezifisch", - "Object_Type")] - + #--------------------------------------------------------------------------- + + if (category == "cubes") { + df_cubes <- binding_lapply(results_json$Cubes, + characteristics = c( + "Code", + "Content", + "Time", + "LatestUpdate", + "State", + "Information" + ) + ) + + df_cubes$Spezifisch <- ggsub(df_cubes) + + df_cubes$Variablen <- spezifisch_create(df_cubes) + + df_cubes$Object_Type <- "Cube" + + #------------------------------------------------------------------------- + + if (nrow(df_cubes) != 0) { + df_cubes$Titel <- titel_search(df_cubes, term) + } + + if (isTRUE(ordering)) { + df_cubes <- df_cubes[with(df_cubes, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Titel", + "Time", + "LatestUpdate", + "State", + "Information", + "Variablen", + "Spezifisch", + "Object_Type" + )] + } else { + df_cubes <- df_cubes[, c( + "Code", + "Content", + "Titel", + "Time", + "LatestUpdate", + "State", + "Information", + "Variablen", + "Spezifisch", + "Object_Type" + )] + } + + #------------------------------------------------------------------------- + + list_resp <- list("Cubes" = tibble::as_tibble(df_cubes)) + + attr(list_resp, "Term") <- results_json$Parameter$term + attr(list_resp, "Language") <- results_json$Parameter$language + attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength + attr(list_resp, "Copyright") <- results_json$Copyright + + return(list_resp) } - - #------------------------------------------------------------------------- - - list_resp <- list("Cubes" = tibble::as_tibble(df_cubes)) - - attr(list_resp, "Term") <- results_json$Parameter$term - attr(list_resp, "Language") <- results_json$Parameter$language - attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength - attr(list_resp, "Copyright") <- results_json$Copyright - - return(list_resp) } - } - #----------------------------------------------------------------------------- + #----------------------------------------------------------------------------- - if (detailed == FALSE) { + if (detailed == FALSE) { + if (category == "all") { + #------------------------------------------------------------------------- - if (category == "all") { - - #------------------------------------------------------------------------- - - df_table <- binding_lapply(results_json$Tables, - characteristics = c("Code", - "Content")) - - df_table$Spezifisch <- ggsub(df_table) - - df_table$Variablen <- spezifisch_create(df_table) - - df_table$Object_Type <- "Table" - - #------------------------------------------------------------------------- + df_table <- binding_lapply(results_json$Tables, + characteristics = c( + "Code", + "Content" + ) + ) - df_stats <- binding_lapply(results_json$Statistics, - characteristics = c("Code", - "Content")) + df_table$Spezifisch <- ggsub(df_table) - df_stats$Spezifisch <- ggsub(df_stats) + df_table$Variablen <- spezifisch_create(df_table) - df_stats$Variablen <- spezifisch_create(df_stats) + df_table$Object_Type <- "Table" - df_stats$Object_Type <- "Statistic" + #------------------------------------------------------------------------- - #------------------------------------------------------------------------- + df_stats <- binding_lapply(results_json$Statistics, + characteristics = c( + "Code", + "Content" + ) + ) - df_variables <- binding_lapply(results_json$Variables, - characteristics = c("Code", - "Content")) + df_stats$Spezifisch <- ggsub(df_stats) - df_variables$Spezifisch <- ggsub(df_variables) + df_stats$Variablen <- spezifisch_create(df_stats) - df_variables$Variablen <- spezifisch_create(df_variables) + df_stats$Object_Type <- "Statistic" - df_variables$Object_Type <- "Variable" + #------------------------------------------------------------------------- - #------------------------------------------------------------------------- + df_variables <- binding_lapply(results_json$Variables, + characteristics = c( + "Code", + "Content" + ) + ) - df_cubes <- binding_lapply(results_json$Cubes, - characteristics = c("Code", - "Content")) + df_variables$Spezifisch <- ggsub(df_variables) - df_cubes$Spezifisch <- ggsub(df_cubes) + df_variables$Variablen <- spezifisch_create(df_variables) - df_cubes$Variablen <- spezifisch_create(df_cubes) + df_variables$Object_Type <- "Variable" - df_cubes$Object_Type <- "Cube" + #------------------------------------------------------------------------- - #------------------------------------------------------------------------- + df_cubes <- binding_lapply(results_json$Cubes, + characteristics = c( + "Code", + "Content" + ) + ) - if (nrow(df_table) != 0) { - df_table$Titel <- titel_search(df_table, term) - } + df_cubes$Spezifisch <- ggsub(df_cubes) - if (nrow(df_stats) != 0) { - df_stats$Titel <- titel_search(df_stats, term) - } + df_cubes$Variablen <- spezifisch_create(df_cubes) - if (nrow(df_variables) != 0) { - df_variables$Titel <- titel_search(df_variables, term) - } + df_cubes$Object_Type <- "Cube" - if (nrow(df_cubes) != 0) { - df_cubes$Titel <- titel_search(df_cubes, term) - } + #------------------------------------------------------------------------- - #------------------------------------------------------------------------- + if (nrow(df_table) != 0) { + df_table$Titel <- titel_search(df_table, term) + } - if(isTRUE(ordering)) { + if (nrow(df_stats) != 0) { + df_stats$Titel <- titel_search(df_stats, term) + } - df_table <- df_table[with(df_table, order(-Titel, -Variablen)), c("Code", - "Content", - "Object_Type")] + if (nrow(df_variables) != 0) { + df_variables$Titel <- titel_search(df_variables, term) + } - df_stats <- df_stats[with(df_stats, order(-Titel, -Variablen)), c( "Code", - "Content", - "Object_Type")] + if (nrow(df_cubes) != 0) { + df_cubes$Titel <- titel_search(df_cubes, term) + } - df_variables <- df_variables[with(df_variables, order(-Titel, -Variablen)), c( "Code", - "Content", - "Object_Type")] + #------------------------------------------------------------------------- - df_cubes <- df_cubes[with(df_cubes, order(-Titel, -Variablen)), c( "Code", - "Content", - "Object_Type")] - } else { + if (isTRUE(ordering)) { + df_table <- df_table[with(df_table, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Object_Type" + )] - df_table <- df_table[, c("Code", - "Content", - "Object_Type")] + df_stats <- df_stats[with(df_stats, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Object_Type" + )] - df_stats <- df_stats[, c("Code", - "Content", - "Object_Type")] + df_variables <- df_variables[with(df_variables, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Object_Type" + )] - df_variables <- df_variables[, c("Code", - "Content", - "Object_Type")] + df_cubes <- df_cubes[with(df_cubes, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Object_Type" + )] + } else { + df_table <- df_table[, c( + "Code", + "Content", + "Object_Type" + )] - df_cubes <- df_cubes[, c("Code", - "Content", - "Object_Type")] + df_stats <- df_stats[, c( + "Code", + "Content", + "Object_Type" + )] + + df_variables <- df_variables[, c( + "Code", + "Content", + "Object_Type" + )] + df_cubes <- df_cubes[, c( + "Code", + "Content", + "Object_Type" + )] + } + + #------------------------------------------------------------------------- + + list_resp <- list( + "Tables" = tibble::as_tibble(df_table), + "Statistics" = tibble::as_tibble(df_stats), + "Variables" = tibble::as_tibble(df_variables), + "Cubes" = tibble::as_tibble(df_cubes) + ) + + attr(list_resp, "Term") <- results_json$Parameter$term + attr(list_resp, "Language") <- results_json$Parameter$language + attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength + attr(list_resp, "Copyright") <- results_json$Copyright + + return(list_resp) } - #------------------------------------------------------------------------- - - list_resp <- list("Tables" = tibble::as_tibble(df_table), - "Statistics" = tibble::as_tibble(df_stats), - "Variables" = tibble::as_tibble(df_variables), - "Cubes" = tibble::as_tibble(df_cubes)) + #--------------------------------------------------------------------------- - attr(list_resp, "Term") <- results_json$Parameter$term - attr(list_resp, "Language") <- results_json$Parameter$language - attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength - attr(list_resp, "Copyright") <- results_json$Copyright + if (category == "tables") { + df_table <- binding_lapply(results_json$Tables, + characteristics = c( + "Code", + "Content" + ) + ) - return(list_resp) + df_table$Spezifisch <- ggsub(df_table) - } + df_table$Variablen <- spezifisch_create(df_table) - #--------------------------------------------------------------------------- + df_table$Object_Type <- "Table" - if (category == "tables") { + #------------------------------------------------------------------------- - df_table <- binding_lapply(results_json$Tables, - characteristics = c("Code", - "Content")) + if (nrow(df_table) != 0) { + df_table$Titel <- titel_search(df_table, term) + } - df_table$Spezifisch <- ggsub(df_table) + if (isTRUE(ordering)) { + df_table <- df_table[with(df_table, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Object_Type" + )] + } else { + df_table <- df_table[, c( + "Code", + "Content", + "Object_Type" + )] + } - df_table$Variablen <- spezifisch_create(df_table) + #------------------------------------------------------------------------- - df_table$Object_Type <- "Table" + list_resp <- list("Tables" = tibble::as_tibble(df_table)) - #------------------------------------------------------------------------- + attr(list_resp, "Term") <- results_json$Parameter$term + attr(list_resp, "Language") <- results_json$Parameter$language + attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength + attr(list_resp, "Copyright") <- results_json$Copyright - if (nrow(df_table) != 0) { - df_table$Titel <- titel_search(df_table, term) + return(list_resp) } - if(isTRUE(ordering)) { - - df_table <- df_table[with(df_table, order(-Titel, -Variablen)), c("Code", - "Content", - "Object_Type")] - - } else { - - df_table <- df_table[, c("Code", - "Content", - "Object_Type")] - - } - - #------------------------------------------------------------------------- - - list_resp <- list("Tables" = tibble::as_tibble(df_table)) + if (category == "statistics") { + df_stats <- binding_lapply(results_json$Statistics, + characteristics = c( + "Code", + "Content" + ) + ) - attr(list_resp, "Term") <- results_json$Parameter$term - attr(list_resp, "Language") <- results_json$Parameter$language - attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength - attr(list_resp, "Copyright") <- results_json$Copyright + df_stats$Spezifisch <- ggsub(df_stats) - return(list_resp) + df_stats$Variablen <- spezifisch_create(df_stats) - } + df_stats$Object_Type <- "Statistic" - if (category == "statistics") { + #------------------------------------------------------------------------- - df_stats <- binding_lapply(results_json$Statistics, - characteristics = c("Code", - "Content")) + if (nrow(df_stats) != 0) { + df_stats$Titel <- titel_search(df_stats, term) + } - df_stats$Spezifisch <- ggsub(df_stats) + if (isTRUE(ordering)) { + df_stats <- df_stats[with(df_stats, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Object_Type" + )] + } else { + df_stats <- df_stats[, c( + "Code", + "Content", + "Object_Type" + )] + } - df_stats$Variablen <- spezifisch_create(df_stats) + #------------------------------------------------------------------------- - df_stats$Object_Type <- "Statistic" + list_resp <- list("Statistics" = tibble::as_tibble(df_stats)) - #------------------------------------------------------------------------- + attr(list_resp, "Term") <- results_json$Parameter$term + attr(list_resp, "Language") <- results_json$Parameter$language + attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength + attr(list_resp, "Copyright") <- results_json$Copyright - if (nrow(df_stats) != 0) { - df_stats$Titel <- titel_search(df_stats, term) + return(list_resp) } - if(isTRUE(ordering)) { - df_stats <- df_stats[with(df_stats, order(-Titel, -Variablen)), c( "Code", - "Content", - "Object_Type")] - - } else { - - df_stats <- df_stats[, c("Code", - "Content", - "Object_Type")] - - } - - #------------------------------------------------------------------------- - - list_resp <- list("Statistics" = tibble::as_tibble(df_stats)) - - attr(list_resp, "Term") <- results_json$Parameter$term - attr(list_resp, "Language") <- results_json$Parameter$language - attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength - attr(list_resp, "Copyright") <- results_json$Copyright - - return(list_resp) - } + #--------------------------------------------------------------------------- - #--------------------------------------------------------------------------- + if (category == "variables") { + df_variables <- binding_lapply(results_json$Variables, + characteristics = c( + "Code", + "Content" + ) + ) - if (category == "variables") { + df_variables$Spezifisch <- ggsub(df_variables) - df_variables <- binding_lapply(results_json$Variables, - characteristics = c("Code", - "Content")) + df_variables$Variablen <- spezifisch_create(df_variables) - df_variables$Spezifisch <- ggsub(df_variables) + df_variables$Object_Type <- "Variable" - df_variables$Variablen <- spezifisch_create(df_variables) + #------------------------------------------------------------------------- - df_variables$Object_Type <- "Variable" + if (nrow(df_variables) != 0) { + df_variables$Titel <- titel_search(df_variables, term) + } - #------------------------------------------------------------------------- + #------------------------------------------------------------------------- - if (nrow(df_variables) != 0) { - df_variables$Titel <- titel_search(df_variables, term) - } + if (isTRUE(ordering)) { + df_variables <- df_variables[with(df_variables, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Object_Type" + )] + } else { + df_variables <- df_variables[, c( + "Code", + "Content", + "Object_Type" + )] + } - #------------------------------------------------------------------------- - - if(isTRUE(ordering)) { + #------------------------------------------------------------------------- - df_variables <- df_variables[with(df_variables, order(-Titel, -Variablen)), c( "Code", - "Content", - "Object_Type")] - - } else { + list_resp <- list("Variables" = tibble::as_tibble(df_variables)) - df_variables <- df_variables[, c("Code", - "Content", - "Object_Type")] + attr(list_resp, "Term") <- results_json$Parameter$term + attr(list_resp, "Language") <- results_json$Parameter$language + attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength + attr(list_resp, "Copyright") <- results_json$Copyright + return(list_resp) } - - #------------------------------------------------------------------------- - - list_resp <- list("Variables" = tibble::as_tibble(df_variables)) - - attr(list_resp, "Term") <- results_json$Parameter$term - attr(list_resp, "Language") <- results_json$Parameter$language - attr(list_resp, "Pagelength") <- results_json$Parameter$pagelength - attr(list_resp, "Copyright") <- results_json$Copyright - - return(list_resp) - } - } #--------------------------------------------------------------------------- if (category == "cubes") { - df_cubes <- binding_lapply(results_json$Cubes, - characteristics = c("Code", - "Content")) + characteristics = c( + "Code", + "Content" + ) + ) df_cubes$Spezifisch <- ggsub(df_cubes) @@ -787,18 +843,18 @@ gen_find <- function(term = NULL, df_cubes$Titel <- titel_search(df_cubes, term) } - if(isTRUE(ordering)) { - - df_cubes <- df_cubes[with(df_cubes, order(-Titel, -Variablen)), c( "Code", - "Content", - "Object_Type")] - + if (isTRUE(ordering)) { + df_cubes <- df_cubes[with(df_cubes, order(-Titel, -Variablen)), c( + "Code", + "Content", + "Object_Type" + )] } else { - - df_cubes <- df_cubes[, c("Code", - "Content", - "Object_Type")] - + df_cubes <- df_cubes[, c( + "Code", + "Content", + "Object_Type" + )] } #------------------------------------------------------------------------- @@ -811,11 +867,8 @@ gen_find <- function(term = NULL, attr(list_resp, "Copyright") <- results_json$Copyright return(list_resp) - } - } return(list_resp) - } diff --git a/R/gen_list_jobs.R b/R/gen_list_jobs.R index 31cdacb..f812d85 100644 --- a/R/gen_list_jobs.R +++ b/R/gen_list_jobs.R @@ -11,19 +11,14 @@ #' gen_list_jobs <- function(selection = NULL, sortcriterion = c("content", "time", "status"), - ... - ) { - + ...) { results_raw <- gen_api("catalogue/jobs", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - selection = selection, - sortcriterion = sortcriterion, - ... - ) + selection = selection, + sortcriterion = sortcriterion, + ... + ) results_json <- test_if_json(results_raw) return(results_json) - } diff --git a/R/gen_meta_data.R b/R/gen_meta_data.R index 5c7c79a..0a603fb 100644 --- a/R/gen_meta_data.R +++ b/R/gen_meta_data.R @@ -16,19 +16,19 @@ #' } #' gen_metadata_stats <- function(code = NULL, - error.ignore = FALSE, - ...) { - - check_function_input(code = code, - error.ignore = error.ignore) + error.ignore = FALSE, + ...) { + check_function_input( + code = code, + error.ignore = error.ignore + ) #----------------------------------------------------------------------------- results_raw <- gen_api("metadata/statistic", - username = gen_auth_get()$username, - password = gen_auth_get()$password, name = code, - ...) + ... + ) results_json <- test_if_json(results_raw) @@ -36,33 +36,30 @@ gen_metadata_stats <- function(code = NULL, #----------------------------------------------------------------------------- - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { df_stats <- "No `meta_information`- object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { df_stats <- results_json$Status$Content - - } else if(empty_object == "DONE"){ - - df_stats <- c("Code" = results_json$Object$Code, - "Content" = results_json$Object$Content, - "Cubes" = results_json$Object$Cubes, - "Variables" = results_json$Object$Variables, - "Information" = results_json$Object$Information, - "Time_from" = results_json$Object$Frequency[[1]]$From, - "Time_to" = results_json$Object$Frequency[[1]]$To, - "Time_type" = results_json$Object$Frequency[[1]]$Type) + } else if (empty_object == "DONE") { + df_stats <- c( + "Code" = results_json$Object$Code, + "Content" = results_json$Object$Content, + "Cubes" = results_json$Object$Cubes, + "Variables" = results_json$Object$Variables, + "Information" = results_json$Object$Information, + "Time_from" = results_json$Object$Frequency[[1]]$From, + "Time_to" = results_json$Object$Frequency[[1]]$To, + "Time_type" = results_json$Object$Frequency[[1]]$Type + ) } - attr(df_stats, "Code") <- results_json$Parameter$name - attr(df_stats, "Method") <- results_json$Ident$Method - attr(df_stats, "Updated") <- results_json$Object$Updated - attr(df_stats, "Language") <- results_json$Parameter$language - attr(df_stats, "Copyright") <- results_json$Copyright + attr(df_stats, "Code") <- results_json$Parameter$name + attr(df_stats, "Method") <- results_json$Ident$Method + attr(df_stats, "Updated") <- results_json$Object$Updated + attr(df_stats, "Language") <- results_json$Parameter$language + attr(df_stats, "Copyright") <- results_json$Copyright - return(df_stats) + return(df_stats) } #------------------------------------------------------------------------------- @@ -85,19 +82,19 @@ gen_metadata_stats <- function(code = NULL, #' } #' gen_metadata_var <- function(code = NULL, - error.ignore = FALSE, - ...) { - - check_function_input(code = code, - error.ignore = error.ignore) + error.ignore = FALSE, + ...) { + check_function_input( + code = code, + error.ignore = error.ignore + ) #----------------------------------------------------------------------------- results_raw <- gen_api("metadata/variable", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - ...) + name = code, + ... + ) results_json <- test_if_json(results_raw) @@ -105,26 +102,25 @@ gen_metadata_var <- function(code = NULL, #----------------------------------------------------------------------------- - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { df_var <- "No `meta_information`- object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { df_var <- results_json$Status$Content - - } else if(empty_object == "DONE"){ - - df_var <- c("Code" = results_json$Object$Code, - "Content" = results_json$Object$Content, - "Values" = results_json$Object$Values, - "Type" = results_json$Object$Type, - "Validity_from" = results_json$Object$Validity$From, - "Validity_to" = results_json$Object$Validity$To) + } else if (empty_object == "DONE") { + df_var <- c( + "Code" = results_json$Object$Code, + "Content" = results_json$Object$Content, + "Values" = results_json$Object$Values, + "Type" = results_json$Object$Type, + "Validity_from" = results_json$Object$Validity$From, + "Validity_to" = results_json$Object$Validity$To + ) } - list_resp <- list("General" = df_var, - "Information" = results_json$Object$Information) + list_resp <- list( + "General" = df_var, + "Information" = results_json$Object$Information + ) attr(list_resp, "Code") <- results_json$Parameter$name attr(list_resp, "Method") <- results_json$Ident$Method @@ -155,19 +151,19 @@ gen_metadata_var <- function(code = NULL, #' } #' gen_metadata_val <- function(code = NULL, - error.ignore = FALSE, - ...) { - - check_function_input(code = code, - error.ignore = error.ignore) + error.ignore = FALSE, + ...) { + check_function_input( + code = code, + error.ignore = error.ignore + ) #----------------------------------------------------------------------------- results_raw <- gen_api("metadata/value", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - ...) + name = code, + ... + ) results_json <- test_if_json(results_raw) @@ -175,23 +171,22 @@ gen_metadata_val <- function(code = NULL, #----------------------------------------------------------------------------- - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { df_value <- "No `meta_information`- object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { df_value <- results_json$Status$Content - - } else if(empty_object == "DONE"){ - - df_value <- c("Code" = results_json$Object$Code, - "Content" = results_json$Object$Content, - "Variables" = results_json$Object$Variables) + } else if (empty_object == "DONE") { + df_value <- c( + "Code" = results_json$Object$Code, + "Content" = results_json$Object$Content, + "Variables" = results_json$Object$Variables + ) } - list_resp <- list("General" = df_value, - "Information" = results_json$Object$Information) + list_resp <- list( + "General" = df_value, + "Information" = results_json$Object$Information + ) attr(list_resp, "Code") <- results_json$Parameter$name attr(list_resp, "Method") <- results_json$Ident$Method @@ -222,19 +217,19 @@ gen_metadata_val <- function(code = NULL, #' } #' gen_metadata_tab <- function(code = NULL, - error.ignore = FALSE, - ...) { - - check_function_input(code = code, - error.ignore = error.ignore) + error.ignore = FALSE, + ...) { + check_function_input( + code = code, + error.ignore = error.ignore + ) #----------------------------------------------------------------------------- results_raw <- gen_api("metadata/table", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - ...) + name = code, + ... + ) results_json <- test_if_json(results_raw) @@ -242,100 +237,102 @@ gen_metadata_tab <- function(code = NULL, #----------------------------------------------------------------------------- - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { char <- "No `meta_information`- object found for your request." structure <- NULL embedded <- NULL - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { char <- results_json$Status$Content structure <- NULL embedded <- NULL - - } else if(empty_object == "DONE"){ - - char <- c("Code" = results_json$Object$Code, - "Content" = results_json$Object$Content, - "Time_From" = results_json$Object$Time$From, - "Time_To" = results_json$Object$Time$To, - "Valid" = results_json$Object$Valid) - - embedded <- cbind("Code" = results_json$Object$Structure$Head$Code, - "Content" = results_json$Object$Structure$Head$Content, - "Type" = results_json$Object$Structure$Head$Type, - "Values" = results_json$Object$Structure$Head$Values, - "Selection" = results_json$Object$Structure$Head$Selected, - "Updated" = results_json$Object$Structure$Head$Updated) + } else if (empty_object == "DONE") { + char <- c( + "Code" = results_json$Object$Code, + "Content" = results_json$Object$Content, + "Time_From" = results_json$Object$Time$From, + "Time_To" = results_json$Object$Time$To, + "Valid" = results_json$Object$Valid + ) + + embedded <- cbind( + "Code" = results_json$Object$Structure$Head$Code, + "Content" = results_json$Object$Structure$Head$Content, + "Type" = results_json$Object$Structure$Head$Type, + "Values" = results_json$Object$Structure$Head$Values, + "Selection" = results_json$Object$Structure$Head$Selected, + "Updated" = results_json$Object$Structure$Head$Updated + ) structure <- list() structure$Head <- if (length(results_json$Object$Structure$Head$Structure) == 1) { - - cbind("Code" = results_json$Object$Structure$Head$Structure[[1]]$Code, - "Content" = results_json$Object$Structure$Head$Structure[[1]]$Content, - "Type" = results_json$Object$Structure$Head$Structure[[1]]$Type, - "Values" = results_json$Object$Structure$Head$Structure[[1]]$Values, - "Selected" = results_json$Object$Structure$Head$Structure[[1]]$Selected, - "Structure" = results_json$Object$Structure$Head$Structure[[1]]$Structure, - "Updated" = results_json$Object$Structure$Head$Structure[[1]]$Updated) - + cbind( + "Code" = results_json$Object$Structure$Head$Structure[[1]]$Code, + "Content" = results_json$Object$Structure$Head$Structure[[1]]$Content, + "Type" = results_json$Object$Structure$Head$Structure[[1]]$Type, + "Values" = results_json$Object$Structure$Head$Structure[[1]]$Values, + "Selected" = results_json$Object$Structure$Head$Structure[[1]]$Selected, + "Structure" = results_json$Object$Structure$Head$Structure[[1]]$Structure, + "Updated" = results_json$Object$Structure$Head$Structure[[1]]$Updated + ) } else { - - cbind("Code" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 1)), - "Content" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 2)), - "Type" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 3)), - "Values" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 4)), - "Selected" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 5)), - "Structure" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 6)), - "Updated" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 7))) + cbind( + "Code" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 1)), + "Content" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 2)), + "Type" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 3)), + "Values" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 4)), + "Selected" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 5)), + "Structure" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 6)), + "Updated" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 7)) + ) } structure$Columns <- if (length(results_json$Object$Structure$Columns) == 1) { - - cbind("Code" = results_json$Object$Structure$Columns[[1]]$Code, - "Content" = results_json$Object$Structure$Columns[[1]]$Content, - "Type" = results_json$Object$Structure$Columns[[1]]$Type, - "Unit" = results_json$Object$Structure$Columns[[1]]$Unit, - "Values" = results_json$Object$Structure$Columns[[1]]$Values, - "Updated" = results_json$Object$Structure$Columns[[1]]$Updated) - + cbind( + "Code" = results_json$Object$Structure$Columns[[1]]$Code, + "Content" = results_json$Object$Structure$Columns[[1]]$Content, + "Type" = results_json$Object$Structure$Columns[[1]]$Type, + "Unit" = results_json$Object$Structure$Columns[[1]]$Unit, + "Values" = results_json$Object$Structure$Columns[[1]]$Values, + "Updated" = results_json$Object$Structure$Columns[[1]]$Updated + ) } else { - - cbind("Code" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 1)), - "Content" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 2)), + cbind( + "Code" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 1)), + "Content" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 2)), "Type" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 3)), "Unit" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 4)), "Values" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 5)), - "Updated" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 6))) - + "Updated" = unlist(lapply(results_json$Object$Structure$Columns, `[[`, 6)) + ) } structure$Rows <- if (length(results_json$Object$Structure$Rows) == 1) { - - cbind("Code" = results_json$Object$Structure$Rows[[1]]$Code, - "Content" = results_json$Object$Structure$Rows[[1]]$Content, + cbind( + "Code" = results_json$Object$Structure$Rows[[1]]$Code, + "Content" = results_json$Object$Structure$Rows[[1]]$Content, "Type" = results_json$Object$Structure$Rows[[1]]$Type, "Unit" = results_json$Object$Structure$Rows[[1]]$Unit, "Values" = results_json$Object$Structure$Rows[[1]]$Values, - "Updated" = results_json$Object$Structure$Rows[[1]]$Updated) - + "Updated" = results_json$Object$Structure$Rows[[1]]$Updated + ) } else { - - cbind("Code" = unlist(lapply(results_json$Object$Structure$Rows, `[[`, 1)), - "Content" = unlist(lapply(results_json$Object$Structure$Rows, `[[`, 2)), + cbind( + "Code" = unlist(lapply(results_json$Object$Structure$Rows, `[[`, 1)), + "Content" = unlist(lapply(results_json$Object$Structure$Rows, `[[`, 2)), "Type" = unlist(lapply(results_json$Object$Structure$Rows, `[[`, 3)), "Unit" = unlist(lapply(results_json$Object$Structure$Rows, `[[`, 4)), "Values" = unlist(lapply(results_json$Object$Structure$Rows, `[[`, 5)), - "Updated" = unlist(lapply(results_json$Object$Structure$Rows, `[[`, 6))) - + "Updated" = unlist(lapply(results_json$Object$Structure$Rows, `[[`, 6)) + ) } } - list_resp <- list("General" = char, - "Structure" = structure, - "Embedded_in" = embedded) + list_resp <- list( + "General" = char, + "Structure" = structure, + "Embedded_in" = embedded + ) attr(list_resp, "Code") <- results_json$Parameter$name attr(list_resp, "Method") <- results_json$Ident$Method @@ -366,19 +363,19 @@ gen_metadata_tab <- function(code = NULL, #' } #' gen_metadata_cube <- function(code = NULL, - error.ignore = FALSE, - ...) { - - check_function_input(code = code, - error.ignore = error.ignore) + error.ignore = FALSE, + ...) { + check_function_input( + code = code, + error.ignore = error.ignore + ) #----------------------------------------------------------------------------- results_raw <- gen_api("metadata/cube", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - ...) + name = code, + ... + ) results_json <- test_if_json(results_raw) @@ -386,78 +383,79 @@ gen_metadata_cube <- function(code = NULL, #----------------------------------------------------------------------------- - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { char <- "No `meta_information`- object found for your request." time <- NULL stat <- NULL structure <- NULL - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { char <- results_json$Status$Content time <- NULL stat <- NULL structure <- NULL - - } else if(empty_object == "DONE"){ - - char <- c("Code" = results_json$Object$Code, - "Content" = results_json$Object$Content, - "State" = results_json$Object$State, - "Values" = results_json$Object$Values) + } else if (empty_object == "DONE") { + char <- c( + "Code" = results_json$Object$Code, + "Content" = results_json$Object$Content, + "State" = results_json$Object$State, + "Values" = results_json$Object$Values + ) time <- unlist(results_json$Object$Timeslices) - stat <- c("Code" = results_json$Object$Statistic$Code, - "Content" = results_json$Object$Statistic$Content, - "Updated" = results_json$Object$Statistic$Updated) + stat <- c( + "Code" = results_json$Object$Statistic$Code, + "Content" = results_json$Object$Statistic$Content, + "Updated" = results_json$Object$Statistic$Updated + ) structure <- list() structure$Axis <- if (length(results_json$Object$Structure$Axis) == 1) { - cbind( "Code" = results_json$Object$Structure$Axis[[1]]$Code, "Content" = results_json$Object$Structure$Axis[[1]]$Content, "Type" = results_json$Object$Structure$Axis[[1]]$Type, - "Updated" = results_json$Object$Structure$Axis[[1]]$Updated) - + "Updated" = results_json$Object$Structure$Axis[[1]]$Updated + ) } else { - cbind( "Code" = unlist(lapply(results_json$Object$Structure$Axis, `[[`, 1)), "Content" = unlist(lapply(results_json$Object$Structure$Axis, `[[`, 2)), "Type" = unlist(lapply(results_json$Object$Structure$Axis, `[[`, 3)), - "Updated" = unlist(lapply(results_json$Object$Structure$Axis, `[[`, 4))) + "Updated" = unlist(lapply(results_json$Object$Structure$Axis, `[[`, 4)) + ) } structure$Content <- if (length(results_json$Object$Structure$Contents) == 1) { - - cbind("Code" = results_json$Object$Structure$Contents[[1]]$Code, - "Content" = results_json$Object$Structure$Contents[[1]]$Content, + cbind( + "Code" = results_json$Object$Structure$Contents[[1]]$Code, + "Content" = results_json$Object$Structure$Contents[[1]]$Content, "Type" = results_json$Object$Structure$Contents[[1]]$Type, "Unit" = results_json$Object$Structure$Contents[[1]]$Unit, "Values" = results_json$Object$Structure$Contents[[1]]$Values, "Updated" = results_json$Object$Structure$Contents[[1]]$Updated, - "Timeslices" = results_json$Object$Structure$Contents[[1]]$Timeslices) - + "Timeslices" = results_json$Object$Structure$Contents[[1]]$Timeslices + ) } else { - - cbind("Code" = unlist(lapply(results_json$Object$Structure$Contents, `[[`, 1)), - "Content" = unlist(lapply(results_json$Object$Structure$Contents, `[[`, 2)), + cbind( + "Code" = unlist(lapply(results_json$Object$Structure$Contents, `[[`, 1)), + "Content" = unlist(lapply(results_json$Object$Structure$Contents, `[[`, 2)), "Type" = unlist(lapply(results_json$Object$Structure$Contents, `[[`, 3)), "Unit" = unlist(lapply(results_json$Object$Structure$Contents, `[[`, 4)), "Values" = unlist(lapply(results_json$Object$Structure$Contents, `[[`, 5)), "Updated" = unlist(lapply(results_json$Object$Structure$Contents, `[[`, 7)), - "Updated" = unlist(lapply(results_json$Object$Structure$Contents, `[[`, 6))) + "Updated" = unlist(lapply(results_json$Object$Structure$Contents, `[[`, 6)) + ) } } - list_resp <- list("General" = char, - "Timespan" = time, - "Statistic_used" = stat, - "Structure" = structure) + list_resp <- list( + "General" = char, + "Timespan" = time, + "Statistic_used" = stat, + "Structure" = structure + ) attr(list_resp, "Code") <- results_json$Parameter$name attr(list_resp, "Method") <- results_json$Ident$Method @@ -489,41 +487,31 @@ gen_metadata_cube <- function(code = NULL, #' } #' gen_metadata <- function(code = NULL, - category = c("Cube", "Statistic", "Table", "Variable", "Value"), - error.ignore = FALSE, - ...) { - + category = c("Cube", "Statistic", "Table", "Variable", "Value"), + error.ignore = FALSE, + ...) { caller <- as.character(match.call()[1]) - check_function_input(code = code, - category = category, - error.ignore = error.ignore, - caller = caller) + check_function_input( + code = code, + category = category, + error.ignore = error.ignore, + caller = caller + ) #----------------------------------------------------------------------------- if (category == "Cube") { - gen_metadata_cube(code = code, error.ignore = error.ignore, ...) - } else if (category == "Value") { - gen_metadata_val(code = code, error.ignore = error.ignore, ...) - } else if (category == "Variable") { - gen_metadata_var(code = code, error.ignore = error.ignore, ...) - } else if (category == "Table") { - gen_metadata_tab(code = code, error.ignore = error.ignore, ...) - } else if (category == "Statistic") { - gen_metadata_stats(code = code, error.ignore = error.ignore, ...) - } else { - stop("Category is not found, please select a correct category. Available categories are Cube, Statistic, Table, Variable, or Value. Please choose one of them.", call. = TRUE) diff --git a/R/gen_modified_data.R b/R/gen_modified_data.R index 1f0143d..0d6ca55 100644 --- a/R/gen_modified_data.R +++ b/R/gen_modified_data.R @@ -26,30 +26,24 @@ gen_modified_data <- function(code = "", type = c("all", "tables", "statistics", "statisticsUpdates"), date = c("now", "week_before", "month_before", "year_before"), ...) { - - date <- check_function_input(code = code, - type = type, - date = date) + date <- check_function_input( + code = code, + type = type, + date = date + ) #----------------------------------------------------------------------------- if (date == "now") { - date <- format(Sys.Date(), format = "%d.%m.%Y") - } else if (date == "week_before") { - date <- format(Sys.Date() - 7, format = "%d.%m.%Y") - } else if (date == "month_before") { - date <- format(Sys.Date() - as.difftime(4, units = "weeks"), - format = "%d.%m.%Y") - + format = "%d.%m.%Y" + ) } else if (date == "year_before") { - date <- format(as.difftime(52, units = "weeks"), format = "%d.%m.%Y") - } type <- match.arg(type) @@ -58,14 +52,12 @@ gen_modified_data <- function(code = "", # Processing #### if (type == "tables") { - results_raw <- gen_api("catalogue/modifieddata", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - selection = code, - type = "Neue Tabellen", - date = date, - ...) + selection = code, + type = "Neue Tabellen", + date = date, + ... + ) results_json <- test_if_json(results_raw) @@ -75,14 +67,12 @@ gen_modified_data <- function(code = "", #----------------------------------------------------------------------------- if (type == "statistics") { - results_raw <- gen_api("catalogue/modifieddata", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - selection = code, - type = "Neue Statistiken", - date = date, - ...) + selection = code, + type = "Neue Statistiken", + date = date, + ... + ) results_json <- test_if_json(results_raw) @@ -92,14 +82,12 @@ gen_modified_data <- function(code = "", #----------------------------------------------------------------------------- if (type == "statisticsUpdates") { - results_raw <- gen_api("catalogue/modifieddata", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - selection = code, - type = "Aktualisierte Statistiken", - date = date, - ...) + selection = code, + type = "Aktualisierte Statistiken", + date = date, + ... + ) results_json <- test_if_json(results_raw) @@ -109,14 +97,12 @@ gen_modified_data <- function(code = "", #----------------------------------------------------------------------------- if (type == "all") { - results_raw <- gen_api("catalogue/modifieddata", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - selection = code, - type = "all", - date = date, - ...) + selection = code, + type = "all", + date = date, + ... + ) results_json <- test_if_json(results_raw) @@ -126,17 +112,17 @@ gen_modified_data <- function(code = "", #----------------------------------------------------------------------------- if (is.null(unlist(results_json$List))) { - message("No modified objects found for your code and date.") - } else { - table <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Date", - "Added", - "Type")) + characteristics = c( + "Code", + "Content", + "Date", + "Added", + "Type" + ) + ) table$Date <- as.Date.character(table$Date, format = "%d.%m.%Y") @@ -154,6 +140,5 @@ gen_modified_data <- function(code = "", attr(list_resp, "Copyright") <- results_json$Copyright return(list_resp) - } } diff --git a/R/gen_objects2stat.R b/R/gen_objects2stat.R index 7f8e491..80cb54e 100644 --- a/R/gen_objects2stat.R +++ b/R/gen_objects2stat.R @@ -15,7 +15,7 @@ #' @examples #' \dontrun{ #' # Find cubes from the statistic with the code "21111" with a detailed return -#' object <- gen_objects2stat(code = "21111", category = "cubes", detailed = T) +#' object <- gen_objects2stat(code = "21111", category = "cubes", detailed = T) #' #' # Find all object types from the statistic with the code "12411" #' object <- gen_objects2stat(code = "12411") @@ -29,156 +29,143 @@ gen_objects2stat <- function(code = NULL, sortcriterion = c("code", "content"), error.ignore = FALSE, ...) { - caller <- as.character(match.call()[1]) - check_function_input(code = code, - category = category, - detailed = detailed, - sortcriterion = sortcriterion, - error.ignore = error.ignore, - caller = caller) + check_function_input( + code = code, + category = category, + detailed = detailed, + sortcriterion = sortcriterion, + error.ignore = error.ignore, + caller = caller + ) sortcriterion <- match.arg(sortcriterion) #------------------------------------------------------------------------------- if ("tables" %in% category) { + results_raw <- gen_api("catalogue/tables2statistic", + name = code, + sortcriterion = sortcriterion, + ... + ) - results_raw <- gen_api("catalogue/tables2statistic", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - sortcriterion = sortcriterion, - ...) - - results_json <- test_if_json(results_raw) - - empty_object <- test_if_error(results_json, para = error.ignore) - - if(isTRUE(empty_object)){ - - df_tables <- "No 'tables' object found for your request." - - } else if(isFALSE(empty_object)){ - - df_tables <- results_json$Status$Content - - } else if(empty_object == "DONE"){ - - if (isTRUE(detailed)) { - - df_tables <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Time")) + results_json <- test_if_json(results_raw) - } else { + empty_object <- test_if_error(results_json, para = error.ignore) - df_tables <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content")) - } + if (isTRUE(empty_object)) { + df_tables <- "No 'tables' object found for your request." + } else if (isFALSE(empty_object)) { + df_tables <- results_json$Status$Content + } else if (empty_object == "DONE") { + if (isTRUE(detailed)) { + df_tables <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Time" + ) + ) + } else { + df_tables <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content" + ) + ) + } df_tables$Object_Type <- "Table" df_tables <- tibble::as_tibble(df_tables) - } + } } #----------------------------------------------------------------------------- if ("variables" %in% category) { - results_raw <- gen_api("catalogue/variables2statistic", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - sortcriterion = sortcriterion, - ...) + name = code, + sortcriterion = sortcriterion, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { df_variables <- "No 'variables' object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { df_variables <- results_json$Status$Content + } else if (empty_object == "DONE") { + if (detailed == TRUE) { + df_variables <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Type", + "Values", + "Information" + ) + ) + } else { + df_variables <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content" + ) + ) + } - } else if(empty_object == "DONE"){ - - if (detailed == TRUE) { - - df_variables <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Type", - "Values", - "Information")) - - } else { - - df_variables <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content")) - - } - - df_variables$Object_Type <- "Variable" + df_variables$Object_Type <- "Variable" - df_variables <- tibble::as_tibble(df_variables) + df_variables <- tibble::as_tibble(df_variables) } } #----------------------------------------------------------------------------- if ("cubes" %in% category) { - results_raw <- gen_api("catalogue/cubes2statistic", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - ...) + name = code, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { df_cubes <- "No 'cubes' object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { df_cubes <- results_json$Status$Content + } else if (empty_object == "DONE") { + if (isTRUE(detailed)) { + df_cubes <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Time", + "State", + "LatestUpdate", + "Information" + ) + ) + } else { + df_cubes <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content" + ) + ) + } - } else if(empty_object == "DONE"){ - - if (isTRUE(detailed)) { - - df_cubes <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Time", - "State", - "LatestUpdate", - "Information")) - - } else { - - df_cubes <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content")) - - } - - df_cubes$Object_Type <- "Cube" + df_cubes$Object_Type <- "Cube" - df_cubes <- tibble::as_tibble(df_cubes) + df_cubes <- tibble::as_tibble(df_cubes) } } @@ -186,22 +173,16 @@ gen_objects2stat <- function(code = NULL, # Summary #### if (all(c("tables", "variables", "cubes") %in% category)) { - list_resp <- list( "Tables" = df_tables, "Variables" = df_variables, - "Cubes" = df_cubes) - + "Cubes" = df_cubes + ) } else if (category == "tables") { - list_resp <- df_tables - } else if (category == "variables") { - list_resp <- df_variables - } else if (category == "cubes") { - list_resp <- df_cubes } @@ -212,5 +193,4 @@ gen_objects2stat <- function(code = NULL, attr(list_resp, "Copyright") <- results_json$Copyright return(list_resp) - } diff --git a/R/gen_objects2var.R b/R/gen_objects2var.R index d5caa1c..f35caa6 100644 --- a/R/gen_objects2var.R +++ b/R/gen_objects2var.R @@ -29,155 +29,142 @@ gen_objects2var <- function(code = NULL, sortcriterion = c("code", "content"), error.ignore = FALSE, ...) { - caller <- as.character(match.call()[1]) - check_function_input(code = code, - category = category, - detailed = detailed, - error.ignore = error.ignore, - sortcriterion = sortcriterion, - caller = caller) + check_function_input( + code = code, + category = category, + detailed = detailed, + error.ignore = error.ignore, + sortcriterion = sortcriterion, + caller = caller + ) sortcriterion <- match.arg(sortcriterion) #----------------------------------------------------------------------------- if ("tables" %in% category) { - results_raw <- gen_api("catalogue/tables2variable", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - sortcriterion = sortcriterion, - ...) + name = code, + sortcriterion = sortcriterion, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { df_tables <- "No 'tables' object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { df_tables <- results_json$Status$Content - - } else if(empty_object == "DONE"){ - - if (isTRUE(detailed)) { - - df_tables <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Time")) - - - } else { - - df_tables <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content")) - - } - - df_tables$Object_Type <- "Table" - - df_tables <- tibble::as_tibble(df_tables) + } else if (empty_object == "DONE") { + if (isTRUE(detailed)) { + df_tables <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Time" + ) + ) + } else { + df_tables <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content" + ) + ) + } + + df_tables$Object_Type <- "Table" + + df_tables <- tibble::as_tibble(df_tables) } } #----------------------------------------------------------------------------- if ("statistics" %in% category) { - results_raw <- gen_api("catalogue/statistics2variable", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - sortcriterion = sortcriterion, - ...) + name = code, + sortcriterion = sortcriterion, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { df_statistics <- "No 'statistics' object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { df_statistics <- results_json$Status$Content - - } else if(empty_object == "DONE"){ - - if (isTRUE(detailed)) { - - df_statistics <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Cubes", - "Information")) - - } else { - - df_statistics <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content")) - } - - df_statistics$Object_Type <- "Statistic" - - df_statistics <- tibble::as_tibble(df_statistics) + } else if (empty_object == "DONE") { + if (isTRUE(detailed)) { + df_statistics <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Cubes", + "Information" + ) + ) + } else { + df_statistics <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content" + ) + ) + } + + df_statistics$Object_Type <- "Statistic" + + df_statistics <- tibble::as_tibble(df_statistics) } } #----------------------------------------------------------------------------- if ("cubes" %in% category) { - results_raw <- gen_api("catalogue/timeseries2variable", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - ...) + name = code, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ - + if (isTRUE(empty_object)) { df_cubes <- "No 'cubes' object found for your request." - - } else if(isFALSE(empty_object)){ - + } else if (isFALSE(empty_object)) { df_cubes <- results_json$Status$Content - - } else if(empty_object == "DONE"){ - - if (isTRUE(detailed)) { - - df_cubes <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Time", - "State", - "LatestUpdate", - "Information")) - - } else { - - df_cubes <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content")) - } - - df_cubes$Object_Type <- "Cube" - - df_cubes <- tibble::as_tibble(df_cubes) + } else if (empty_object == "DONE") { + if (isTRUE(detailed)) { + df_cubes <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Time", + "State", + "LatestUpdate", + "Information" + ) + ) + } else { + df_cubes <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content" + ) + ) + } + + df_cubes$Object_Type <- "Cube" + + df_cubes <- tibble::as_tibble(df_cubes) } } @@ -185,25 +172,17 @@ gen_objects2var <- function(code = NULL, # Summary #### if (all(c("tables", "statistics", "cubes") %in% category)) { - list_resp <- list( "Tables" = df_tables, "Statistics" = df_statistics, "Cubes" = df_cubes ) - } else if (category == "tables") { - list_resp <- df_tables - } else if (category == "statistics") { - list_resp <- df_statistics - } else if (category == "cubes") { - list_resp <- df_cubes - } attr(list_resp, "Code") <- results_json$Parameter$term @@ -213,5 +192,4 @@ gen_objects2var <- function(code = NULL, attr(list_resp, "Copyright") <- results_json$Copyright return(list_resp) - } diff --git a/R/gen_table.R b/R/gen_table.R index 67a7b37..7eac965 100644 --- a/R/gen_table.R +++ b/R/gen_table.R @@ -44,9 +44,7 @@ #' } #' gen_table <- function(name, ...) { - gen_table_(name, ...) - } #------------------------------------------------------------------------------- @@ -67,11 +65,13 @@ gen_table_ <- function(name, classifyingkey3 = NULL, stand = NULL, language = Sys.getenv("GENESIS_LANG")) { - area <- match.arg(area) if (!isTRUE(language == "en")) { - area <- switch(area, public = "\u00F6ffentlich", user = "benutzer") + area <- switch(area, + public = "\u00F6ffentlich", + user = "benutzer" + ) } param_check_year(startyear) diff --git a/R/gen_var2-val2.R b/R/gen_var2-val2.R index c44f4c9..74d1d1c 100644 --- a/R/gen_var2-val2.R +++ b/R/gen_var2-val2.R @@ -23,11 +23,12 @@ gen_var2stat <- function(code = NULL, sortcriterion = c("code", "content"), error.ignore = FALSE, ...) { - - check_function_input(code = code, - detailed = detailed, - error.ignore = error.ignore, - sortcriterion = sortcriterion) + check_function_input( + code = code, + detailed = detailed, + error.ignore = error.ignore, + sortcriterion = sortcriterion + ) sortcriterion <- match.arg(sortcriterion) @@ -35,42 +36,42 @@ gen_var2stat <- function(code = NULL, # Processing #### results_raw <- gen_api("catalogue/variables2statistic", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - sortcriterion = sortcriterion, - ...) + name = code, + sortcriterion = sortcriterion, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ + if (isTRUE(empty_object)) { list_of_variables <- "No `variables`- object found for your request." - } else if(isFALSE(empty_object)){ + } else if (isFALSE(empty_object)) { list_of_variables <- results_json$Status$Content - } else if(empty_object == "DONE"){ - if (isTRUE(detailed)) { - - list_of_variables <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Type", - "Values", - "Information")) - - } else { + } else if (empty_object == "DONE") { + if (isTRUE(detailed)) { + list_of_variables <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Type", + "Values", + "Information" + ) + ) + } else { + list_of_variables <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content" + ) + ) + } + + list_of_variables$Object_Type <- "Variable" - list_of_variables <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content" - )) - - } - - list_of_variables$Object_Type <- "Variable" - - list_of_variables <- tibble::as_tibble(list_of_variables) + list_of_variables <- tibble::as_tibble(list_of_variables) } # Summary #### @@ -82,7 +83,6 @@ gen_var2stat <- function(code = NULL, attr(list_resp, "Copyright") <- results_json$Copyright return(list_resp) - } #------------------------------------------------------------------------------- @@ -106,44 +106,46 @@ gen_var2stat <- function(code = NULL, #' } #' gen_val2var <- function(code = NULL, - sortcriterion = c("code", "content"), - error.ignore = FALSE, - ...) { - - check_function_input(code = code, - error.ignore = error.ignore, - sortcriterion = sortcriterion) + sortcriterion = c("code", "content"), + error.ignore = FALSE, + ...) { + check_function_input( + code = code, + error.ignore = error.ignore, + sortcriterion = sortcriterion + ) sortcriterion <- match.arg(sortcriterion) #----------------------------------------------------------------------------- results_raw <- gen_api("catalogue/values2variable", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - name = code, - sortcriterion = sortcriterion, - ...) + name = code, + sortcriterion = sortcriterion, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ + if (isTRUE(empty_object)) { list_of_variables <- "No `values`- object found for your request." - } else if(isFALSE(empty_object)){ + } else if (isFALSE(empty_object)) { list_of_variables <- results_json$Status$Content - } else if(empty_object == "DONE"){ - list_of_variables <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Variables", - "Information")) + } else if (empty_object == "DONE") { + list_of_variables <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Variables", + "Information" + ) + ) list_of_variables$Object_Type <- "Value" list_of_variables <- tibble::as_tibble(list_of_variables) - } list_resp <- list("Values" = list_of_variables) @@ -156,7 +158,6 @@ gen_val2var <- function(code = NULL, names(list_resp) <- paste("Values of", results_json$Parameter$name) return(list_resp) - } #------------------------------------------------------------------------------- @@ -186,37 +187,39 @@ gen_val2var2stat <- function(code = NULL, sortcriterion = c("code", "content"), error.ignore = FALSE, ...) { - - check_function_input(code = code, - detailed = detailed, - error.ignore = error.ignore, - sortcriterion = sortcriterion) + check_function_input( + code = code, + detailed = detailed, + error.ignore = error.ignore, + sortcriterion = sortcriterion + ) sortcriterion <- match.arg(sortcriterion) #----------------------------------------------------------------------------- - variables <- suppressMessages(suppressWarnings(gen_var2stat(code = code, - detailed = detailed, - sortcriterion = sortcriterion, - error.ignore = error.ignore, - ...))) + variables <- suppressMessages(suppressWarnings(gen_var2stat( + code = code, + detailed = detailed, + sortcriterion = sortcriterion, + error.ignore = error.ignore, + ... + ))) list_values <- list() lapply(variables$Variables$Code, function(x) { - - zwisch <- suppressMessages(suppressWarnings(gen_val2var(code = x, - sortcriterion = sortcriterion, - error.ignore = error.ignore))) + zwisch <- suppressMessages(suppressWarnings(gen_val2var( + code = x, + sortcriterion = sortcriterion, + error.ignore = error.ignore + ))) list_values <<- append(list_values, zwisch) - }) list_resp <- list(variables, list_values) return(list_resp) - } #------------------------------------------------------------------------------- @@ -243,43 +246,46 @@ gen_search_vars <- function(code = NULL, sortcriterion = c("code", "content"), error.ignore = FALSE, ...) { - caller <- as.character(match.call()[1]) - check_function_input(code = code, - error.ignore = error.ignore, - sortcriterion = sortcriterion, - caller = caller) + check_function_input( + code = code, + error.ignore = error.ignore, + sortcriterion = sortcriterion, + caller = caller + ) sortcriterion <- match.arg(sortcriterion) #----------------------------------------------------------------------------- results_raw <- gen_api("catalogue/variables", - username = gen_auth_get()$username, - password = gen_auth_get()$password, - selection = code, - sortcriterion = sortcriterion, - ...) + selection = code, + sortcriterion = sortcriterion, + ... + ) results_json <- test_if_json(results_raw) empty_object <- test_if_error(results_json, para = error.ignore) - if(isTRUE(empty_object)){ + if (isTRUE(empty_object)) { list_of_variables <- "No `variables`- object found for your request." - } else if(isFALSE(empty_object)){ + } else if (isFALSE(empty_object)) { list_of_variables <- results_json$Status$Content - } else if(empty_object == "DONE"){ - list_of_variables <- binding_lapply(results_json$List, - characteristics = c("Code", - "Content", - "Type", - "Information")) + } else if (empty_object == "DONE") { + list_of_variables <- binding_lapply(results_json$List, + characteristics = c( + "Code", + "Content", + "Type", + "Information" + ) + ) - list_of_variables$Object_Type <- "Variable" + list_of_variables$Object_Type <- "Variable" - list_of_variables <- tibble::as_tibble(list_of_variables) + list_of_variables <- tibble::as_tibble(list_of_variables) } list_resp <- list("Variables" = list_of_variables) @@ -290,5 +296,4 @@ gen_search_vars <- function(code = NULL, attr(list_resp, "Copyright") <- results_json$Copyright return(list_resp) - } diff --git a/R/utils.R b/R/utils.R index 68b0843..fc14bc5 100644 --- a/R/utils.R +++ b/R/utils.R @@ -5,14 +5,11 @@ resp_check_data_csv <- function(resp) { } param_check_year <- function(year) { - - if (as.integer(year) < 1900 || as.integer(year) > 2100) { - + if (as.integer(year) < 1900 || as.integer(year) > 2100) { stop("The parameter 'year' has been misspecified (>= 1900 or <= 2100).", - call. = FALSE) - + call. = FALSE + ) } - } param_collapse_vec <- function(vec) { @@ -268,28 +265,22 @@ check_function_input <- function(code = NULL, # date ---- if (!is.null(date)) { - if (identical(date, c("now", "week_before", "month_before", "year_before"))) { - message("Please note that this date is calculated automatically and may differ from manually entered data. Manually entered data must have the format DD.MM.YYYY.") return("now") - } if (!(length(date) %in% c(1, 4))) { - stop("Parameter 'date' has to be of length 4 (c('now', 'week_before', 'month_before', 'year_before') for the default option of 'now' or of length 1.))", - call. = FALSE) - + call. = FALSE + ) } if (length(date) == 1) { - if (date %in% c("now", "week_before", "month_before", "year_before")) { - message("Please note that this date is calculated automatically and may differ from manually entered data. Manually entered data must have the format DD.MM.YYYY.") @@ -298,17 +289,16 @@ check_function_input <- function(code = NULL, } if (!(date %in% c("now", "week_before", "month_before", "year_before"))) { - if (!is.character(date)) { - stop("If using a specific date for parameter 'date', it has to be of type 'character' (format: DD.MM.YYYY).", - call. = FALSE) - + call. = FALSE + ) } if (length(date) != 1 || nchar(date) != 10) { stop("If specifying a specific date for parameter 'date', it has to be of length 1 and format DD.MM.YYYY.", - call. = FALSE) + call. = FALSE + ) } return(date) From eb22b3921896da28bdde9b72d1759c67da0f7c06 Mon Sep 17 00:00:00 2001 From: KovaZo <87823821+KovaZo@users.noreply.github.com> Date: Tue, 27 Jun 2023 09:04:25 +0200 Subject: [PATCH 4/8] changes in function titles and description --- R/data.R | 2 +- R/gen_alternative_terms.R | 6 +- R/gen_api.R | 2 +- R/gen_auth.R | 2 +- R/gen_catalogue.R | 4 +- R/gen_cube.R | 4 +- R/gen_find.R | 4 +- R/gen_list_jobs.R | 4 +- R/gen_meta_data.R | 14 +- R/gen_modified_data.R | 4 +- R/gen_objects2stat.R | 6 +- R/gen_objects2var.R | 2 +- R/gen_table.R | 4 +- R/gen_var2-val2.R | 12 +- R/utils.R | 1030 ++++++++++++++++++------------------- R/zzz.R | 10 +- 16 files changed, 555 insertions(+), 555 deletions(-) diff --git a/R/data.R b/R/data.R index 02ea390..532eb59 100644 --- a/R/data.R +++ b/R/data.R @@ -1,4 +1,4 @@ -#' List of EVAS codes +#' List of EVAS Codes #' #' @format ## `evas_list_long_20220724` #' A data frame with 1,097 rows and 3 columns: diff --git a/R/gen_alternative_terms.R b/R/gen_alternative_terms.R index e6b563e..d248f1c 100644 --- a/R/gen_alternative_terms.R +++ b/R/gen_alternative_terms.R @@ -1,10 +1,10 @@ -#' gen_alternative_terms: Call for similar or spelling related terms for further search +#’ Search for Related Terms Based on the Same Specific String #' -#' @description Function to find search terms that are similar or related to one another and also represented in Genesis. +#' @description Function to find terms in Genesis that are similar or related based on a simple comparison of strings. This can help to identify alternative search terms. #' #' @param term Character string. Maximum length of 15 characters. Term or word for which you are searching for alternative or related terms. Use of '*' as a placeholder is possible to generate broader search areas. #' @param similarity Logical. Indicator if the output of the function should be sorted based on a Levenshtein edit distance based on the \code{adist()} function. -#' @param ... Additional parameters for the Genesis API call. These parameters are only affecting the Genesis call itself, no further processing. +#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. #' #' @return A list with all recalled elements from Genesis. Attributes are added to the data.frame, describing the search configuration for the returned output. #' @export diff --git a/R/gen_api.R b/R/gen_api.R index e11faf0..6bc01b9 100644 --- a/R/gen_api.R +++ b/R/gen_api.R @@ -1,4 +1,4 @@ -#' Low-level function to interact with the Destatis GENESIS API +#' Lower-Level Function to Interact With the Genesis API #' #' @param endpoint Self-explanatory #' diff --git a/R/gen_auth.R b/R/gen_auth.R index fff9ff7..a43d8dc 100644 --- a/R/gen_auth.R +++ b/R/gen_auth.R @@ -1,4 +1,4 @@ -#' Save authentication +#’ Save Authentication of Your Genesis Account #' #' See Details. #' diff --git a/R/gen_catalogue.R b/R/gen_catalogue.R index cc3557d..e48854f 100644 --- a/R/gen_catalogue.R +++ b/R/gen_catalogue.R @@ -1,6 +1,6 @@ -#' catalogue: Explore Different Objects and Their Structural Embedding in Genesis +#' Explore Different Objects and Their Structural Embedding in Genesis #' -#' Function to enable searching for tables, statistics, and cubes from Genesis. Additionally, it structures the output based on the internal tree structure of Genesis itself based on the EVAS-numbers. Time-series are represented as cubes with a specified time span. +#' @description Function to enable searching for tables, statistics, and cubes from Genesis. Additionally, it structures the output based on the internal tree structure of Genesis itself based on the EVAS-numbers. Time-series are represented as cubes with a specified time span. #' #' @param code a string with a maximum length of 10 characters. Code from a Genesis-Object. Only one code per iteration. "*"-Notations are possible. #' @param category a string. Specific Genesis-Object-types: 'tables', 'statistics', and 'cubes'. All three together are possible. diff --git a/R/gen_cube.R b/R/gen_cube.R index 84f5b02..a3fbbb5 100644 --- a/R/gen_cube.R +++ b/R/gen_cube.R @@ -1,6 +1,6 @@ -#' gen_cube +#’ Get the Data of a Cube From Genesis #' -#' @description Download a cube with data from Genesis +#' @description Download a cube with data from Genesis. #' #' @param name Name of the data cube #' @param ... Optional parameters passed on to the Genesis API call: diff --git a/R/gen_find.R b/R/gen_find.R index 596d4cc..a5ed130 100644 --- a/R/gen_find.R +++ b/R/gen_find.R @@ -1,4 +1,4 @@ -#' gen_find +#' General Search for Objects Through Genesis #' #' @description Function to search through Genesis. It is similar in usage as the search function on the Destatis main page (https://www.destatis.de/DE/Home/_inhalt.html). #' In the search query, "UND" (german word for: and; can also be written "und" or "&") as well as "ODER" (german word for: or; can also be written "oder" or "|") can be included and logically combined. Furthermore, wildcards are possible by including "*". If more then one word is included in the term-string, automatically "and" is used to combine the different words. @@ -9,7 +9,7 @@ #' @param detailed A logical. Indicator if the function should return the detailed output of the iteration including all object related information or only a shortened output including only code and object title. Default Option is FALSE. #' @param ordering A logical. Indicator if the function should return the output of the iteration ordered first based on the fact if the searched term is appearing in the title of the object and secondly on an estimator of the number of variables in this object. Default option is TRUE. #' @param error.ignore A logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce an artificial response (e.g., for complex processes not to fail). -#' @param ... Additional parameters of the Genesis API call. These parameters are only affecting the Genesis API call itself, there is no further processing. +#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. #' #' @return A list with all elements retrieved from Genesis. Attributes are added to the data.frame describing the search configuration for the returned output. #' @export diff --git a/R/gen_list_jobs.R b/R/gen_list_jobs.R index f812d85..aa76a06 100644 --- a/R/gen_list_jobs.R +++ b/R/gen_list_jobs.R @@ -1,10 +1,10 @@ -#' gen_list_jobs: Explore current jobs of your user account +#' Search for Current Jobs of Your User Account #' #' @description Function to list all current jobs connected to the given user. #' #' @param selection Filter the list of jobs for matching codes. #' @param sortcriterion Allows to sort the resulting list of jobs by their Code ("content"), the time of completion ("time") or status ("status") -#' @param ... Further parameters to be passed down to the API caller. +#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. #' #' @return A list of all current jobs connected to the given user. #' @export diff --git a/R/gen_meta_data.R b/R/gen_meta_data.R index 0a603fb..2e58cec 100644 --- a/R/gen_meta_data.R +++ b/R/gen_meta_data.R @@ -1,4 +1,4 @@ -#' gen_metadata_stat +#' Search for Meta-Information for a Statistic #' #' @description Function to search for meta-information for a specific statistic. #' @@ -64,7 +64,7 @@ gen_metadata_stats <- function(code = NULL, #------------------------------------------------------------------------------- -#' gen_metadata_var +#' Search for Meta-Information for a Variable #' #' @description Function to search for meta-information for a specific variable. #' @@ -133,7 +133,7 @@ gen_metadata_var <- function(code = NULL, #------------------------------------------------------------------------------- -#' gen_metadata_val +#' Search for Meta-Information for a Value #' #' @description Function to search for meta-information for a specific value. #' @@ -199,7 +199,7 @@ gen_metadata_val <- function(code = NULL, #------------------------------------------------------------------------------- -#' gen_metadata_tab +#' Search for Meta-Information for a Table #' #' @description Function to search for meta-information for a specific table. #' @@ -345,7 +345,7 @@ gen_metadata_tab <- function(code = NULL, #------------------------------------------------------------------------------- -#' gen_metadata_cube +#' Search for Meta-Information for a Cube #' #' @description Function to search for meta-information for a specific cube. #' @@ -468,9 +468,9 @@ gen_metadata_cube <- function(code = NULL, #------------------------------------------------------------------------------- -#' gen_metadata +#’ Search for Meta-Information for All Types of Objects #' -#' @description Search For Meta-Information For All Types Of Objects +#' @description Function to search for meta-information for all types of objects. #' #' @param code string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. #' @param category a string. Specific object-types: 'Cube', 'Statistic', "Table", "Variable" and 'Value'. The function needs a specified object type. diff --git a/R/gen_modified_data.R b/R/gen_modified_data.R index 0d6ca55..d98fceb 100644 --- a/R/gen_modified_data.R +++ b/R/gen_modified_data.R @@ -1,11 +1,11 @@ -#' gen_modified_data: Explore New Added Objects or Changed Objects in Genesis +#' Search for Newly Added Objects or Documented Changes to Objects in Genesis #' #' @description Function to check for updates, changes, or new objects in Genesis based on a specific date. #' #' @param code a string with a maximum length of 15 characters. Code from a Genesis object. Only one code per iteration. "*" notations are possible. Empty code (default value) includes all changes, updates, and new added objects. #' @param type a string. Specific Genesis object type: 'tables', 'statistics', and 'statisticsUpdates'. All three can be accessed through "all", which is the default. #' @param date a string. Specific date that is used as the last update or upload time in Genesis to include a Genesis object in return. Default option is 'now', which uses the current date of your system. Alternative options are 'week_before', using the current date of your system minus 7 days, 'month_before', using the current date of your system minus 4 weeks, and 'year_before', using the current date of your system minus 52 weeks. Additionally, it is possible to fill in a specific date of format 'DD.MM.YYYY'. -#' @param ... Additional parameters for the Genesis call. These parameters are only affecting the Genesis call itself, not the further processing. +#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. #' #' @return A list with all recalled elements from Genesis. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output. #' @export diff --git a/R/gen_objects2stat.R b/R/gen_objects2stat.R index 80cb54e..84f2d89 100644 --- a/R/gen_objects2stat.R +++ b/R/gen_objects2stat.R @@ -1,6 +1,6 @@ -#' gen_objects2stat: Get Objects Related To Statistics +#' Search for Objects Related to a Statistic #' -#' Function to find objects related to a statistic in Genesis. +#' @description Function to find objects related to a statistic in Genesis. #' #' @param code a string with a maximum length of 6 characters (15 characters if cubes are not used as a category). Code from a Genesis-Object. Only one code per iteration. #' @param category a string. Specific object-types: 'tables', 'variables', and 'cubes'. All three together are possible and the default option. @@ -9,7 +9,7 @@ #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. #' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from Genesis. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples diff --git a/R/gen_objects2var.R b/R/gen_objects2var.R index f35caa6..919f2e6 100644 --- a/R/gen_objects2var.R +++ b/R/gen_objects2var.R @@ -1,4 +1,4 @@ -#' gen_objects2var: Get Objects Related To Variable +#' Search for Objects Related to a Variable #' #' @description Function to find objects related to a variable in Genesis. #' diff --git a/R/gen_table.R b/R/gen_table.R index 7eac965..faa6953 100644 --- a/R/gen_table.R +++ b/R/gen_table.R @@ -1,6 +1,6 @@ -#' gen_table +#’ Get the Data of a Table From Genesis #' -#' @description Download a table with data from Genesis +#' @description Download a table with data from Genesis. #' #' @param name a string. Name of the table. Use of wildcards (`*`) allowed. #' @param ... Optional parameters passed on to the Genesis API call: diff --git a/R/gen_var2-val2.R b/R/gen_var2-val2.R index 74d1d1c..b2a5f04 100644 --- a/R/gen_var2-val2.R +++ b/R/gen_var2-val2.R @@ -1,4 +1,4 @@ -#' gen_var2stat: Get Variables From a Statistic +#' Search for the Variables From a Statistic #' #' @description Function to generate variables from statistics in Genesis. #' @@ -87,7 +87,7 @@ gen_var2stat <- function(code = NULL, #------------------------------------------------------------------------------- -#' gen_val2var: Get Values From a Variable +#' Search for the Values of a Variable #' #' @description Function to extract the possible values from a variable from Genesis. Values for continuous variables are not extractable, so the function returns a warning message. #' @@ -162,15 +162,15 @@ gen_val2var <- function(code = NULL, #------------------------------------------------------------------------------- -#' gen_val2var2stat: Get Values From a Variable From a Statistic +#' Search for the Variables and Their Values From a Statistic #' -#' @description Get values from variables from a statistic. Values for continuous variables cannot be extracted, so the function returns a warning message. +#' @description Function to extract the possible values from a variable from a statistic in Genesis. Values for continuous variables are not extractable, so the function returns a warning message. #' #' @param code a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder. #' @param detailed a logical. Indicator if function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. This parameter only affects the details of the variables-related output. The default is FALSE. #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. #' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is an parameter of the Genesis API call itself. The default is "code". -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself for the variables, no further processing or the values-related objects. +#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself for the variables, no further processing for the values-related objects. #' #' @return A list with all recalled elements from Genesis. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export @@ -224,7 +224,7 @@ gen_val2var2stat <- function(code = NULL, #------------------------------------------------------------------------------- -#' gen_search_vars: Search for Specific Variables +#' Search for a Specific Variable #' #' @description Function to search for specific variables in Genesis. #' diff --git a/R/utils.R b/R/utils.R index fc14bc5..d7e540d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,515 +1,515 @@ -resp_check_data_csv <- function(resp) { - if (httr2::resp_content_type(resp) != "text/csv") { - stop("No data found that meets the specified parameters", call. = FALSE) - } -} - -param_check_year <- function(year) { - if (as.integer(year) < 1900 || as.integer(year) > 2100) { - stop("The parameter 'year' has been misspecified (>= 1900 or <= 2100).", - call. = FALSE - ) - } -} - -param_collapse_vec <- function(vec) { - paste0(vec, collapse = ",") -} - -#------------------------------------------------------------------------------- - -# Forming_evas ---- - -forming_evas <- function(list_of) { - evas_list_long_20220724 <- restatis::evas_list_long_20220724 - - # Progress them - list_of$Main <- apply(list_of, 1, function(x) { - evas_list_long_20220724$Titel[evas_list_long_20220724$EVAS == substr(x["Code"], 1, 1)] - }) - - list_of$Main2 <- apply(list_of, 1, function(x) { - evas_list_long_20220724$Titel[evas_list_long_20220724$EVAS == substr(x["Code"], 1, 2)] - }) - - list_of$Main3 <- apply(list_of, 1, function(x) { - evas_list_long_20220724$Titel[evas_list_long_20220724$EVAS == substr(x["Code"], 1, 3)] - }) - - list_of$Main5 <- apply(list_of, 1, function(x) { - evas_list_long_20220724$Titel[evas_list_long_20220724$EVAS == substr(x["Code"], 1, 5)] - }) - - nestedlist <- split(list_of, list_of$Main, drop = TRUE) - - nestedlist <- lapply(nestedlist, function(x) { - split(x, x["Main2"], drop = TRUE) - }) - - nestedlist <- lapply(nestedlist, function(x) { - lapply(x, function(y) { - split(y, y["Main3"]) - }) - }) - - nestedlist <- lapply(nestedlist, function(x) { - lapply(x, function(y) { - lapply(y, function(z) { - split(z, z["Main5"]) - }) - }) - }) - - aba <- lapply( - nestedlist, function(d) { - lapply(d, function(z) { - lapply(z, function(y) { - lapply(y, function(x) { - x[!( - names(x) - %in% c("Main", "Main2", "Main3", "Main5"))] - }) - }) - }) - } - ) - - return(aba) -} - -#------------------------------------------------------------------------------- - -# check_function_input ---- - -check_function_input <- function(code = NULL, - term = NULL, - sortcriterion = NULL, - category = NULL, - detailed = NULL, - type = NULL, - date = NULL, - similarity = NULL, - error.ignore = NULL, - ordering = NULL, - caller = NULL) { - # Code & Term ---- - - if (is.null(code) && is.null(term)) { - if (!(caller %in% c( - "gen_search_vars", - "restatis::gen_search_vars" - ))) { - stop("Parameter 'code' or 'term' must NOT be NULL.", - call. = FALSE - ) - } - } - - # Code ---- - - if (!is.null(code)) { - if (length(code) != 1L) { - stop("Parameter 'code' must be a single string.", - call. = FALSE - ) - } - - if (!is.character(code)) { - stop("Parameter 'code' has to be of type 'character'.", - call. = FALSE - ) - } - } - - # Term ---- - - if (!is.null(term)) { - if (length(term) != 1L) { - stop("Parameter 'term' must be a single string.", - call. = FALSE - ) - } - - if (!is.character(term)) { - stop("Parameter 'term' has to be of type 'character'.", - call. = FALSE - ) - } - - if (nchar(term) > 15 && !(caller %in% c("gen_find", "restatis::gen_find"))) { - stop("Parameter 'term' cannot consist of more than 15 characters.", - call. = FALSE - ) - } - } - - # sortcriterion ---- - - if (!is.null(sortcriterion)) { - if (!is.character(sortcriterion)) { - stop("Parameter 'sortcriterion' has to be of type 'character'.", - call. = FALSE - ) - } - - if (length(sortcriterion) == 1) { - if (!(sortcriterion %in% c("code", "content"))) { - stop("Parameter 'sortcriterion' has to be 'code' or 'content'.", - call. = FALSE - ) - } - } - } - - # category ---- - - if (!is.null(category)) { - if (!(length(category) %in% c(1:3)) && caller %in% c( - "restatis::gen_catalogue", - "restatis::gen_objects2var", - "restatis::gen_objects2stat", - "gen_catalogue", - "gen_objects2var", - "gen_objects2stat" - )) { - stop("Parameter 'category' has to have a length of 1 to 3.") - } - - #---------------------------------------- - - if (!(length(category) %in% c(1, 5)) && caller %in% c( - "restatis::gen_find", - "gen_find" - )) { - stop("Parameter 'category' must have a length of 1.") - } - - #---------------------------------------- - - if (length(category) != 1 && caller %in% c( - "restatis::gen_metadata", - "gen_metadata" - )) { - stop("Parameter 'category' must have a length of 1. Please specify the category.") - } - - #--------------------------------------------------------------------------- - - if (caller %in% c( - "restatis::gen_catalogue", "restatis::gen_objects2var", - "gen_catalogue", "gen_objects2var" - )) { - if (!all(category %in% c("tables", "cubes", "statistics"))) { - stop("Available categories are tables, statistics, and cubes.", - call. = FALSE - ) - } - } - - #---------------------------------------- - - if (caller %in% c("restatis::gen_objects2stat", "gen_objects2stat")) { - if (!all(category %in% c("tables", "cubes", "variables"))) { - stop("Available categories are tables, variables, and cubes.", - call. = FALSE - ) - } - } - - #---------------------------------------- - - if (caller %in% c("restatis::gen_find", "gen_find")) { - if (!all(category %in% c("all", "tables", "statistics", "variables", "cubes"))) { - stop("Available categories are all, tables, statistics, variables, and cubes.", - call. = FALSE - ) - } - } - - #---------------------------------------- - - if (caller %in% c("restatis::gen_metadata", "gen_metadata")) { - if (!all(category %in% c("Cube", "Statistic", "Table", "Variable", "Value"))) { - stop("Available categories are Cube, Table, Statistic, Variable, and Value.", - call. = FALSE - ) - } - } - } - - - # detailed ---- - - if (!is.null(detailed)) { - if (!is.logical(detailed) || length(detailed) != 1) { - stop("Parameter 'detailed' has to be of type 'logical' and of length 1.", - call. = FALSE - ) - } - - if (isFALSE(detailed)) { - message("Use 'detailed = TRUE' to obtain the complete output.") - } - } - - # type ---- - - if (!is.null(type)) { - if (!all(type %in% c("all", "tables", "statistics", "statisticsUpdates"))) { - stop("Available categories for parameter 'type' are 'tables', 'statistics', 'statistic updates', and 'all'.", - call. = FALSE - ) - } - } - - # date ---- - - if (!is.null(date)) { - if (identical(date, c("now", "week_before", "month_before", "year_before"))) { - message("Please note that this date is calculated automatically and may differ - from manually entered data. Manually entered data must have - the format DD.MM.YYYY.") - - return("now") - } - - if (!(length(date) %in% c(1, 4))) { - stop("Parameter 'date' has to be of length 4 (c('now', 'week_before', 'month_before', 'year_before') for the default option of 'now' or of length 1.))", - call. = FALSE - ) - } - - if (length(date) == 1) { - if (date %in% c("now", "week_before", "month_before", "year_before")) { - message("Please note that this date is calculated automatically and may differ - from manually entered data. Manually entered data must have - the format DD.MM.YYYY.") - - return(date) - } - - if (!(date %in% c("now", "week_before", "month_before", "year_before"))) { - if (!is.character(date)) { - stop("If using a specific date for parameter 'date', it has to be of type 'character' (format: DD.MM.YYYY).", - call. = FALSE - ) - } - - if (length(date) != 1 || nchar(date) != 10) { - stop("If specifying a specific date for parameter 'date', it has to be of length 1 and format DD.MM.YYYY.", - call. = FALSE - ) - } - - return(date) - } - } - } - - # similarity ---- - - if (!is.null(similarity)) { - if (!is.logical(similarity)) { - stop("Parameter 'similarity' has to be of type 'logical'.", - call. = FALSE - ) - } - } - - # error.ignore ---- - - if (!is.null(error.ignore)) { - if (length(error.ignore == 1)) { - if (!is.logical(error.ignore) || length(error.ignore) != 1) { - stop("Parameter 'error.ignore' has to be of type 'logical' and of length 1.", - call. = FALSE - ) - } - } - - if (isTRUE(error.ignore)) { - message("Use 'error.ignore = FALSE' to stop the function at the point where no object could be found.") - } - } - - # ordering ---- - - if (!is.null(ordering)) { - if (!is.logical(ordering) || length(ordering) != 1) { - stop("Parameter 'ordering' has to be of type 'logical' and of length 1.", - call. = FALSE - ) - } - - if (isFALSE(ordering)) { - message("Use 'ordering = TRUE' to obtain the output ordered based on the search term presence.") - } - } -} - -#------------------------------------------------------------------------------- - -# test_if_json ---- - -test_if_json <- function(input) { - if ((httr2::resp_content_type(input) == "application/json") && !is.na(httr2::resp_content_type(input))) { - results_json <- httr2::resp_body_json(input) - } else { - stop("No json-csv file detected.", call. = FALSE) - } - - return(results_json) -} - -#------------------------------------------------------------------------------- - -# test_if_error_find ---- - -test_if_error_find <- function(input, para) { - if (input$Status$Code != 0 && isTRUE(para)) { - stop(input$Status$Content) - } else if (input$Status$Code != 0 && isFALSE(para)) { - message(input$Status$Content) - - message("Artificial token is used.") - - empty_object <- FALSE - } else { - empty_object <- "DONE" - } - - return(empty_object) -} - -#------------------------------------------------------------------------------- - -# test_if_error ---- - -test_if_error <- function(input, para) { - if (input$Status$Code == 104 && isFALSE(para)) { - stop("No object found for your request. Check your parameters if you expected an object for this request.", - call. = FALSE - ) - } else if (input$Status$Code != 0 && isFALSE(para)) { - stop(input$Status$Content, call. = FALSE) - } else if (input$Status$Code == 104 && isTRUE(para)) { - message("No object found for your request. Check your parameters if you expected an object for this request. Artificial token is used.") - - empty_object <- TRUE - } else if (input$Status$Code != 0 && isTRUE(para)) { - message(input$Status$Content) - - message("Artificial token is used.") - - empty_object <- FALSE - } else { - empty_object <- "DONE" - } - - return(empty_object) -} - -#------------------------------------------------------------------------------- - -# test_if_process_further ---- - -test_if_process_further <- function(input, para) { - if (sum(unlist(lapply(input[4:8], function(x) { - is.null(x) - }))) == 5 && isFALSE(para)) { - stop("No object found for your request. Check your parameters if you expected an object for this request.") - } else if (sum(unlist(lapply(input[4:8], function(x) { - is.null(x) - }))) == 5 && isTRUE(para)) { - message("No object found for your request. Check your parameters if you expected an object for this request. Artificial token is used.") - - empty_object <- TRUE - } else { - empty_object <- "DONE" - } - - return(empty_object) -} - -#------------------------------------------------------------------------------- - -# binding_lapply ---- - -binding_lapply <- function(x, - characteristics) { - list_of <- stats::setNames(data.frame(matrix(ncol = length(characteristics), nrow = 0)), characteristics) - - lapply(x, function(x) { - zwisch <- unlist(x[characteristics]) - - list_of <<- rbind(list_of, zwisch[characteristics]) - }) - - colnames(list_of) <- characteristics - - return(list_of) -} - -#------------------------------------------------------------------------------- - -# gsub ---- - -ggsub <- function(x) { - a <- gsub(".*:", "", x$Content) - - return(a) -} - -#------------------------------------------------------------------------------- - -# spezifisch_create ---- - -spezifisch_create <- function(x) { - a <- unlist(lapply(strsplit(x$Spezifisch, ","), length)) - - return(a) -} - -#------------------------------------------------------------------------------- - -# titel_search ---- - -titel_search <- function(x, term) { - split <- unlist(strsplit(gsub(" ", "und", term), c("und|UND|Und|\\&|ODER|oder|Oder|\\|"))) - - split <- split[sapply(split, function(y) { - nchar(y) > 0 - })] - - if (length(split) == 1) { - a <- grepl(split, x$Content, ignore.case = TRUE) - } else if (grep("ODER|oder|Oder|\\|", term, ignore.case = TRUE) && grep("UND|und|Und|\\|", term, ignore.case = TRUE)) { - a <- rep(FALSE, length(x$Content)) - message("Combination of words too complex for ordering. Data is processed without ordering.") - } else if (grep("ODER|oder|Oder|\\|", term, ignore.case = TRUE)) { - a <- grepl(paste(split, collapse = "|"), x$Content, ignore.case = TRUE) - } else if (grep("UND|und|Und|\\|", term, ignore.case = TRUE)) { - a <- sapply(x$Content, function(con) { - all(sapply(split, function(z) { - grepl(z, con, ignore.case = TRUE) - })) - }) - } else { - a <- rep(FALSE, length(x$Content)) - - message("Combination of words not valid for ordering. Data is processed without ordering.") - } - - return(a) -} - - -#------------------------------------------------------------------------------- - -# test_if_error_light ---- - -test_if_error_light <- function(input) { - if (input$Status$Code != 0) { - warning(input$Status$Content, call. = FALSE) - } -} +resp_check_data_csv <- function(resp) { + if (httr2::resp_content_type(resp) != "text/csv") { + stop("No data found that meets the specified parameters", call. = FALSE) + } +} + +param_check_year <- function(year) { + if (as.integer(year) < 1900 || as.integer(year) > 2100) { + stop("The parameter 'year' has been misspecified (>= 1900 or <= 2100).", + call. = FALSE + ) + } +} + +param_collapse_vec <- function(vec) { + paste0(vec, collapse = ",") +} + +#------------------------------------------------------------------------------- + +# Forming_evas ---- + +forming_evas <- function(list_of) { + evas_list_long_20220724 <- restatis::evas_list_long_20220724 + + # Progress them + list_of$Main <- apply(list_of, 1, function(x) { + evas_list_long_20220724$Titel[evas_list_long_20220724$EVAS == substr(x["Code"], 1, 1)] + }) + + list_of$Main2 <- apply(list_of, 1, function(x) { + evas_list_long_20220724$Titel[evas_list_long_20220724$EVAS == substr(x["Code"], 1, 2)] + }) + + list_of$Main3 <- apply(list_of, 1, function(x) { + evas_list_long_20220724$Titel[evas_list_long_20220724$EVAS == substr(x["Code"], 1, 3)] + }) + + list_of$Main5 <- apply(list_of, 1, function(x) { + evas_list_long_20220724$Titel[evas_list_long_20220724$EVAS == substr(x["Code"], 1, 5)] + }) + + nestedlist <- split(list_of, list_of$Main, drop = TRUE) + + nestedlist <- lapply(nestedlist, function(x) { + split(x, x["Main2"], drop = TRUE) + }) + + nestedlist <- lapply(nestedlist, function(x) { + lapply(x, function(y) { + split(y, y["Main3"]) + }) + }) + + nestedlist <- lapply(nestedlist, function(x) { + lapply(x, function(y) { + lapply(y, function(z) { + split(z, z["Main5"]) + }) + }) + }) + + aba <- lapply( + nestedlist, function(d) { + lapply(d, function(z) { + lapply(z, function(y) { + lapply(y, function(x) { + x[!( + names(x) + %in% c("Main", "Main2", "Main3", "Main5"))] + }) + }) + }) + } + ) + + return(aba) +} + +#------------------------------------------------------------------------------- + +# check_function_input ---- + +check_function_input <- function(code = NULL, + term = NULL, + sortcriterion = NULL, + category = NULL, + detailed = NULL, + type = NULL, + date = NULL, + similarity = NULL, + error.ignore = NULL, + ordering = NULL, + caller = NULL) { + # Code & Term ---- + + if (is.null(code) && is.null(term)) { + if (!(caller %in% c( + "gen_search_vars", + "restatis::gen_search_vars" + ))) { + stop("Parameter 'code' or 'term' must NOT be NULL.", + call. = FALSE + ) + } + } + + # Code ---- + + if (!is.null(code)) { + if (length(code) != 1L) { + stop("Parameter 'code' must be a single string.", + call. = FALSE + ) + } + + if (!is.character(code)) { + stop("Parameter 'code' has to be of type 'character'.", + call. = FALSE + ) + } + } + + # Term ---- + + if (!is.null(term)) { + if (length(term) != 1L) { + stop("Parameter 'term' must be a single string.", + call. = FALSE + ) + } + + if (!is.character(term)) { + stop("Parameter 'term' has to be of type 'character'.", + call. = FALSE + ) + } + + if (nchar(term) > 15 && !(caller %in% c("gen_find", "restatis::gen_find"))) { + stop("Parameter 'term' cannot consist of more than 15 characters.", + call. = FALSE + ) + } + } + + # sortcriterion ---- + + if (!is.null(sortcriterion)) { + if (!is.character(sortcriterion)) { + stop("Parameter 'sortcriterion' has to be of type 'character'.", + call. = FALSE + ) + } + + if (length(sortcriterion) == 1) { + if (!(sortcriterion %in% c("code", "content"))) { + stop("Parameter 'sortcriterion' has to be 'code' or 'content'.", + call. = FALSE + ) + } + } + } + + # category ---- + + if (!is.null(category)) { + if (!(length(category) %in% c(1:3)) && caller %in% c( + "restatis::gen_catalogue", + "restatis::gen_objects2var", + "restatis::gen_objects2stat", + "gen_catalogue", + "gen_objects2var", + "gen_objects2stat" + )) { + stop("Parameter 'category' has to have a length of 1 to 3.") + } + + #---------------------------------------- + + if (!(length(category) %in% c(1, 5)) && caller %in% c( + "restatis::gen_find", + "gen_find" + )) { + stop("Parameter 'category' must have a length of 1.") + } + + #---------------------------------------- + + if (length(category) != 1 && caller %in% c( + "restatis::gen_metadata", + "gen_metadata" + )) { + stop("Parameter 'category' must have a length of 1. Please specify the category.") + } + + #--------------------------------------------------------------------------- + + if (caller %in% c( + "restatis::gen_catalogue", "restatis::gen_objects2var", + "gen_catalogue", "gen_objects2var" + )) { + if (!all(category %in% c("tables", "cubes", "statistics"))) { + stop("Available categories are tables, statistics, and cubes.", + call. = FALSE + ) + } + } + + #---------------------------------------- + + if (caller %in% c("restatis::gen_objects2stat", "gen_objects2stat")) { + if (!all(category %in% c("tables", "cubes", "variables"))) { + stop("Available categories are tables, variables, and cubes.", + call. = FALSE + ) + } + } + + #---------------------------------------- + + if (caller %in% c("restatis::gen_find", "gen_find")) { + if (!all(category %in% c("all", "tables", "statistics", "variables", "cubes"))) { + stop("Available categories are all, tables, statistics, variables, and cubes.", + call. = FALSE + ) + } + } + + #---------------------------------------- + + if (caller %in% c("restatis::gen_metadata", "gen_metadata")) { + if (!all(category %in% c("Cube", "Statistic", "Table", "Variable", "Value"))) { + stop("Available categories are Cube, Table, Statistic, Variable, and Value.", + call. = FALSE + ) + } + } + } + + + # detailed ---- + + if (!is.null(detailed)) { + if (!is.logical(detailed) || length(detailed) != 1) { + stop("Parameter 'detailed' has to be of type 'logical' and of length 1.", + call. = FALSE + ) + } + + if (isFALSE(detailed)) { + message("Use 'detailed = TRUE' to obtain the complete output.") + } + } + + # type ---- + + if (!is.null(type)) { + if (!all(type %in% c("all", "tables", "statistics", "statisticsUpdates"))) { + stop("Available categories for parameter 'type' are 'tables', 'statistics', 'statistic updates', and 'all'.", + call. = FALSE + ) + } + } + + # date ---- + + if (!is.null(date)) { + if (identical(date, c("now", "week_before", "month_before", "year_before"))) { + message("Please note that this date is calculated automatically and may differ + from manually entered data. Manually entered data must have + the format DD.MM.YYYY.") + + return("now") + } + + if (!(length(date) %in% c(1, 4))) { + stop("Parameter 'date' has to be of length 4 (c('now', 'week_before', 'month_before', 'year_before') for the default option of 'now' or of length 1.))", + call. = FALSE + ) + } + + if (length(date) == 1) { + if (date %in% c("now", "week_before", "month_before", "year_before")) { + message("Please note that this date is calculated automatically and may differ + from manually entered data. Manually entered data must have + the format DD.MM.YYYY.") + + return(date) + } + + if (!(date %in% c("now", "week_before", "month_before", "year_before"))) { + if (!is.character(date)) { + stop("If using a specific date for parameter 'date', it has to be of type 'character' (format: DD.MM.YYYY).", + call. = FALSE + ) + } + + if (length(date) != 1 || nchar(date) != 10) { + stop("If specifying a specific date for parameter 'date', it has to be of length 1 and format DD.MM.YYYY.", + call. = FALSE + ) + } + + return(date) + } + } + } + + # similarity ---- + + if (!is.null(similarity)) { + if (!is.logical(similarity)) { + stop("Parameter 'similarity' has to be of type 'logical'.", + call. = FALSE + ) + } + } + + # error.ignore ---- + + if (!is.null(error.ignore)) { + if (length(error.ignore == 1)) { + if (!is.logical(error.ignore) || length(error.ignore) != 1) { + stop("Parameter 'error.ignore' has to be of type 'logical' and of length 1.", + call. = FALSE + ) + } + } + + if (isTRUE(error.ignore)) { + message("Use 'error.ignore = FALSE' to stop the function at the point where no object could be found.") + } + } + + # ordering ---- + + if (!is.null(ordering)) { + if (!is.logical(ordering) || length(ordering) != 1) { + stop("Parameter 'ordering' has to be of type 'logical' and of length 1.", + call. = FALSE + ) + } + + if (isFALSE(ordering)) { + message("Use 'ordering = TRUE' to obtain the output ordered based on the search term presence.") + } + } +} + +#------------------------------------------------------------------------------- + +# test_if_json ---- + +test_if_json <- function(input) { + if ((httr2::resp_content_type(input) == "application/json") && !is.na(httr2::resp_content_type(input))) { + results_json <- httr2::resp_body_json(input) + } else { + stop("No json-csv file detected.", call. = FALSE) + } + + return(results_json) +} + +#------------------------------------------------------------------------------- + +# test_if_error_find ---- + +test_if_error_find <- function(input, para) { + if (input$Status$Code != 0 && isTRUE(para)) { + stop(input$Status$Content) + } else if (input$Status$Code != 0 && isFALSE(para)) { + message(input$Status$Content) + + message("Artificial token is used.") + + empty_object <- FALSE + } else { + empty_object <- "DONE" + } + + return(empty_object) +} + +#------------------------------------------------------------------------------- + +# test_if_error ---- + +test_if_error <- function(input, para) { + if (input$Status$Code == 104 && isFALSE(para)) { + stop("No object found for your request. Check your parameters if you expected an object for this request.", + call. = FALSE + ) + } else if (input$Status$Code != 0 && isFALSE(para)) { + stop(input$Status$Content, call. = FALSE) + } else if (input$Status$Code == 104 && isTRUE(para)) { + message("No object found for your request. Check your parameters if you expected an object for this request. Artificial token is used.") + + empty_object <- TRUE + } else if (input$Status$Code != 0 && isTRUE(para)) { + message(input$Status$Content) + + message("Artificial token is used.") + + empty_object <- FALSE + } else { + empty_object <- "DONE" + } + + return(empty_object) +} + +#------------------------------------------------------------------------------- + +# test_if_process_further ---- + +test_if_process_further <- function(input, para) { + if (sum(unlist(lapply(input[4:8], function(x) { + is.null(x) + }))) == 5 && isFALSE(para)) { + stop("No object found for your request. Check your parameters if you expected an object for this request.") + } else if (sum(unlist(lapply(input[4:8], function(x) { + is.null(x) + }))) == 5 && isTRUE(para)) { + message("No object found for your request. Check your parameters if you expected an object for this request. Artificial token is used.") + + empty_object <- TRUE + } else { + empty_object <- "DONE" + } + + return(empty_object) +} + +#------------------------------------------------------------------------------- + +# binding_lapply ---- + +binding_lapply <- function(x, + characteristics) { + list_of <- stats::setNames(data.frame(matrix(ncol = length(characteristics), nrow = 0)), characteristics) + + lapply(x, function(x) { + zwisch <- unlist(x[characteristics]) + + list_of <<- rbind(list_of, zwisch[characteristics]) + }) + + colnames(list_of) <- characteristics + + return(list_of) +} + +#------------------------------------------------------------------------------- + +# gsub ---- + +ggsub <- function(x) { + a <- gsub(".*:", "", x$Content) + + return(a) +} + +#------------------------------------------------------------------------------- + +# spezifisch_create ---- + +spezifisch_create <- function(x) { + a <- unlist(lapply(strsplit(x$Spezifisch, ","), length)) + + return(a) +} + +#------------------------------------------------------------------------------- + +# titel_search ---- + +titel_search <- function(x, term) { + split <- unlist(strsplit(gsub(" ", "und", term), c("und|UND|Und|\\&|ODER|oder|Oder|\\|"))) + + split <- split[sapply(split, function(y) { + nchar(y) > 0 + })] + + if (length(split) == 1) { + a <- grepl(split, x$Content, ignore.case = TRUE) + } else if (grep("ODER|oder|Oder|\\|", term, ignore.case = TRUE) && grep("UND|und|Und|\\|", term, ignore.case = TRUE)) { + a <- rep(FALSE, length(x$Content)) + message("Combination of words too complex for ordering. Data is processed without ordering.") + } else if (grep("ODER|oder|Oder|\\|", term, ignore.case = TRUE)) { + a <- grepl(paste(split, collapse = "|"), x$Content, ignore.case = TRUE) + } else if (grep("UND|und|Und|\\|", term, ignore.case = TRUE)) { + a <- sapply(x$Content, function(con) { + all(sapply(split, function(z) { + grepl(z, con, ignore.case = TRUE) + })) + }) + } else { + a <- rep(FALSE, length(x$Content)) + + message("Combination of words not valid for ordering. Data is processed without ordering.") + } + + return(a) +} + + +#------------------------------------------------------------------------------- + +# test_if_error_light ---- + +test_if_error_light <- function(input) { + if (input$Status$Code != 0) { + warning(input$Status$Content, call. = FALSE) + } +} diff --git a/R/zzz.R b/R/zzz.R index 5564489..5fa2183 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,5 +1,5 @@ -.onLoad <- function(libname, pkgname) { - gen_api <<- memoise::memoise(gen_api) - - if (!nzchar(Sys.getenv("GENESIS_LANG"))) Sys.setenv(GENESIS_LANG = "en") -} +.onLoad <- function(libname, pkgname) { + gen_api <<- memoise::memoise(gen_api) + + if (!nzchar(Sys.getenv("GENESIS_LANG"))) Sys.setenv(GENESIS_LANG = "en") +} From a2b10c5cfffff7845e26bad381553dac0e1e1ca9 Mon Sep 17 00:00:00 2001 From: "long.nguyen" Date: Tue, 27 Jun 2023 11:05:41 +0200 Subject: [PATCH 5/8] Rerender docs --- R/gen_alternative_terms.R | 8 +++---- R/gen_api.R | 2 +- R/gen_auth.R | 10 ++++---- R/gen_catalogue.R | 14 ++++++------ R/gen_cube.R | 6 ++--- R/gen_find.R | 16 ++++++------- R/gen_list_jobs.R | 2 +- R/gen_meta_data.R | 38 +++++++++++++++--------------- R/gen_modified_data.R | 14 ++++++------ R/gen_objects2stat.R | 10 ++++---- R/gen_objects2var.R | 10 ++++---- R/gen_table.R | 6 ++--- R/gen_var2-val2.R | 42 +++++++++++++++++----------------- R/restatis-package.R | 6 +++++ man/evas_list_long_20220724.Rd | 4 ++-- man/gen_alternative_terms.Rd | 8 +++---- man/gen_auth_save.Rd | 6 ++--- man/gen_catalogue.Rd | 14 ++++++------ man/gen_cube.Rd | 6 ++--- man/gen_find.Rd | 16 ++++++------- man/gen_list_jobs.Rd | 4 ++-- man/gen_metadata.Rd | 10 ++++---- man/gen_metadata_cube.Rd | 8 +++---- man/gen_metadata_stats.Rd | 8 +++---- man/gen_metadata_tab.Rd | 8 +++---- man/gen_metadata_val.Rd | 8 +++---- man/gen_metadata_var.Rd | 8 +++---- man/gen_modified_data.Rd | 14 ++++++------ man/gen_objects2stat.Rd | 14 ++++++------ man/gen_objects2var.Rd | 12 +++++----- man/gen_search_vars.Rd | 14 ++++++------ man/gen_table.Rd | 6 ++--- man/gen_val2var.Rd | 12 +++++----- man/gen_val2var2stat.Rd | 12 +++++----- man/gen_var2stat.Rd | 12 +++++----- man/restatis-package.Rd | 32 ++++++++++++++++++++++++++ 36 files changed, 229 insertions(+), 191 deletions(-) create mode 100644 R/restatis-package.R create mode 100644 man/restatis-package.Rd diff --git a/R/gen_alternative_terms.R b/R/gen_alternative_terms.R index d248f1c..fc243d0 100644 --- a/R/gen_alternative_terms.R +++ b/R/gen_alternative_terms.R @@ -1,12 +1,12 @@ -#’ Search for Related Terms Based on the Same Specific String +#' Search for Related Terms Based on the Same Specific String #' -#' @description Function to find terms in Genesis that are similar or related based on a simple comparison of strings. This can help to identify alternative search terms. +#' @description Function to find terms in GENESIS that are similar or related based on a simple comparison of strings. This can help to identify alternative search terms. #' #' @param term Character string. Maximum length of 15 characters. Term or word for which you are searching for alternative or related terms. Use of '*' as a placeholder is possible to generate broader search areas. #' @param similarity Logical. Indicator if the output of the function should be sorted based on a Levenshtein edit distance based on the \code{adist()} function. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Attributes are added to the data.frame, describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Attributes are added to the data.frame, describing the search configuration for the returned output. #' @export #' #' @examples diff --git a/R/gen_api.R b/R/gen_api.R index 6bc01b9..68f4174 100644 --- a/R/gen_api.R +++ b/R/gen_api.R @@ -1,4 +1,4 @@ -#' Lower-Level Function to Interact With the Genesis API +#' Lower-Level Function to Interact With the GENESIS API #' #' @param endpoint Self-explanatory #' diff --git a/R/gen_auth.R b/R/gen_auth.R index a43d8dc..0e6fdc0 100644 --- a/R/gen_auth.R +++ b/R/gen_auth.R @@ -1,13 +1,13 @@ -#’ Save Authentication of Your Genesis Account +#' Save Authentication of Your GENESIS Account #' #' See Details. #' -#' Genesis username and password are encrypted and saved as RDS in the +#' GENESIS username and password are encrypted and saved as RDS in the #' package config directory. #' #' A random string is generated and stored in the session environment #' variable `RESTATIS_KEY`. This string is used as the key to encrypt and -#' decrypt the entered Genesis credentials. +#' decrypt the entered GENESIS credentials. #' #' To avoid having to save authentication in future sessions, `RESTATIS_KEY` can #' be added to .Renviron. The usethis package includes a helper function for @@ -54,8 +54,8 @@ gen_auth_get <- function() { if (!(file.exists(auth_path) && nzchar(Sys.getenv("RESTATIS_KEY")))) { stop( - "Genesis credentials not found.\n", - "Please run `gen_auth_save()` to store Genesis username and password.\n", + "GENESIS credentials not found.\n", + "Please run `gen_auth_save()` to store GENESIS username and password.\n", call. = FALSE ) } diff --git a/R/gen_catalogue.R b/R/gen_catalogue.R index e48854f..29f8ddc 100644 --- a/R/gen_catalogue.R +++ b/R/gen_catalogue.R @@ -1,15 +1,15 @@ -#' Explore Different Objects and Their Structural Embedding in Genesis +#' Explore Different Objects and Their Structural Embedding in GENESIS #' -#' @description Function to enable searching for tables, statistics, and cubes from Genesis. Additionally, it structures the output based on the internal tree structure of Genesis itself based on the EVAS-numbers. Time-series are represented as cubes with a specified time span. +#' @description Function to enable searching for tables, statistics, and cubes from GENESIS. Additionally, it structures the output based on the internal tree structure of GENESIS itself based on the EVAS-numbers. Time-series are represented as cubes with a specified time span. #' -#' @param code a string with a maximum length of 10 characters. Code from a Genesis-Object. Only one code per iteration. "*"-Notations are possible. -#' @param category a string. Specific Genesis-Object-types: 'tables', 'statistics', and 'cubes'. All three together are possible. +#' @param code a string with a maximum length of 10 characters. Code from a GENESIS-Object. Only one code per iteration. "*"-Notations are possible. +#' @param category a string. Specific GENESIS-Object-types: 'tables', 'statistics', and 'cubes'. All three together are possible. #' @param detailed a logical. Indicator if the function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. -#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. +#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis API. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS API. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples diff --git a/R/gen_cube.R b/R/gen_cube.R index a3fbbb5..ffe05f9 100644 --- a/R/gen_cube.R +++ b/R/gen_cube.R @@ -1,9 +1,9 @@ -#’ Get the Data of a Cube From Genesis +#' Get the Data of a Cube From GENESIS #' -#' @description Download a cube with data from Genesis. +#' @description Download a cube with data from GENESIS. #' #' @param name Name of the data cube -#' @param ... Optional parameters passed on to the Genesis API call: +#' @param ... Optional parameters passed on to the GENESIS API call: #' \describe{ #' \item{\code{area}}{a string. The area in which the table is stored. Possible values: #' \itemize{ diff --git a/R/gen_find.R b/R/gen_find.R index a5ed130..6cdbb66 100644 --- a/R/gen_find.R +++ b/R/gen_find.R @@ -1,6 +1,6 @@ -#' General Search for Objects Through Genesis +#' General Search for Objects Through GENESIS #' -#' @description Function to search through Genesis. It is similar in usage as the search function on the Destatis main page (https://www.destatis.de/DE/Home/_inhalt.html). +#' @description Function to search through GENESIS. It is similar in usage as the search function on the Destatis main page (https://www.destatis.de/DE/Home/_inhalt.html). #' In the search query, "UND" (german word for: and; can also be written "und" or "&") as well as "ODER" (german word for: or; can also be written "oder" or "|") can be included and logically combined. Furthermore, wildcards are possible by including "*". If more then one word is included in the term-string, automatically "and" is used to combine the different words. #' Important note: Time-series are treated as cubes, they are not longer distinguished. If you want to find a specific object with a clear code with this find function, you need to specify the object type or search for all object types. #' @@ -9,23 +9,23 @@ #' @param detailed A logical. Indicator if the function should return the detailed output of the iteration including all object related information or only a shortened output including only code and object title. Default Option is FALSE. #' @param ordering A logical. Indicator if the function should return the output of the iteration ordered first based on the fact if the searched term is appearing in the title of the object and secondly on an estimator of the number of variables in this object. Default option is TRUE. #' @param error.ignore A logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce an artificial response (e.g., for complex processes not to fail). -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all elements retrieved from Genesis. Attributes are added to the data.frame describing the search configuration for the returned output. +#' @return A list with all elements retrieved from GENESIS. Attributes are added to the data.frame describing the search configuration for the returned output. #' @export #' #' @examples #' \dontrun{ -#' # Find objects related to "bus" in Genesis +#' # Find objects related to "bus" in GENESIS #' object <- gen_find(term = "bus") #' -#' # Find tables related to "bus" in Genesis and return a unordered detailed output +#' # Find tables related to "bus" in GENESIS and return a unordered detailed output #' object <- gen_find(term = "bus", detailed = TRUE, ordering = FALSE) #' -#' # Find tables related to "Autos" or "Corona" in Genesis and return a unordered detailed output +#' # Find tables related to "Autos" or "Corona" in GENESIS and return a unordered detailed output #' object <- gen_find(term = "autos ODER corona", detailed = TRUE, ordering = FALSE) #' -#' #' # Find tables related to "Autos" and "Corona" in Genesis and return a unordered detailed output +#' #' # Find tables related to "Autos" and "Corona" in GENESIS and return a unordered detailed output #' object <- gen_find(term = "autos UND corona", detailed = TRUE, ordering = FALSE) #' } #' diff --git a/R/gen_list_jobs.R b/R/gen_list_jobs.R index aa76a06..e17d709 100644 --- a/R/gen_list_jobs.R +++ b/R/gen_list_jobs.R @@ -4,7 +4,7 @@ #' #' @param selection Filter the list of jobs for matching codes. #' @param sortcriterion Allows to sort the resulting list of jobs by their Code ("content"), the time of completion ("time") or status ("status") -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' #' @return A list of all current jobs connected to the given user. #' @export diff --git a/R/gen_meta_data.R b/R/gen_meta_data.R index 2e58cec..43da045 100644 --- a/R/gen_meta_data.R +++ b/R/gen_meta_data.R @@ -2,11 +2,11 @@ #' #' @description Function to search for meta-information for a specific statistic. #' -#' @param code a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. +#' @param code a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples @@ -68,11 +68,11 @@ gen_metadata_stats <- function(code = NULL, #' #' @description Function to search for meta-information for a specific variable. #' -#' @param code a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. "*"-Notation is possible. +#' @param code a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. "*"-Notation is possible. #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples @@ -137,11 +137,11 @@ gen_metadata_var <- function(code = NULL, #' #' @description Function to search for meta-information for a specific value. #' -#' @param code a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. +#' @param code a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples @@ -203,11 +203,11 @@ gen_metadata_val <- function(code = NULL, #' #' @description Function to search for meta-information for a specific table. #' -#' @param code a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. +#' @param code a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples @@ -349,11 +349,11 @@ gen_metadata_tab <- function(code = NULL, #' #' @description Function to search for meta-information for a specific cube. #' -#' @param code a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. +#' @param code a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples @@ -468,16 +468,16 @@ gen_metadata_cube <- function(code = NULL, #------------------------------------------------------------------------------- -#’ Search for Meta-Information for All Types of Objects +#' Search for Meta-Information for All Types of Objects #' #' @description Function to search for meta-information for all types of objects. #' -#' @param code string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. +#' @param code string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. #' @param category a string. Specific object-types: 'Cube', 'Statistic', "Table", "Variable" and 'Value'. The function needs a specified object type. #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples diff --git a/R/gen_modified_data.R b/R/gen_modified_data.R index d98fceb..d54fd00 100644 --- a/R/gen_modified_data.R +++ b/R/gen_modified_data.R @@ -1,13 +1,13 @@ -#' Search for Newly Added Objects or Documented Changes to Objects in Genesis +#' Search for Newly Added Objects or Documented Changes to Objects in GENESIS #' -#' @description Function to check for updates, changes, or new objects in Genesis based on a specific date. +#' @description Function to check for updates, changes, or new objects in GENESIS based on a specific date. #' -#' @param code a string with a maximum length of 15 characters. Code from a Genesis object. Only one code per iteration. "*" notations are possible. Empty code (default value) includes all changes, updates, and new added objects. -#' @param type a string. Specific Genesis object type: 'tables', 'statistics', and 'statisticsUpdates'. All three can be accessed through "all", which is the default. -#' @param date a string. Specific date that is used as the last update or upload time in Genesis to include a Genesis object in return. Default option is 'now', which uses the current date of your system. Alternative options are 'week_before', using the current date of your system minus 7 days, 'month_before', using the current date of your system minus 4 weeks, and 'year_before', using the current date of your system minus 52 weeks. Additionally, it is possible to fill in a specific date of format 'DD.MM.YYYY'. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param code a string with a maximum length of 15 characters. Code from a GENESIS object. Only one code per iteration. "*" notations are possible. Empty code (default value) includes all changes, updates, and new added objects. +#' @param type a string. Specific GENESIS object type: 'tables', 'statistics', and 'statisticsUpdates'. All three can be accessed through "all", which is the default. +#' @param date a string. Specific date that is used as the last update or upload time in GENESIS to include a GENESIS object in return. Default option is 'now', which uses the current date of your system. Alternative options are 'week_before', using the current date of your system minus 7 days, 'month_before', using the current date of your system minus 4 weeks, and 'year_before', using the current date of your system minus 52 weeks. Additionally, it is possible to fill in a specific date of format 'DD.MM.YYYY'. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output. #' @export #' #' @examples diff --git a/R/gen_objects2stat.R b/R/gen_objects2stat.R index 84f2d89..4b904bc 100644 --- a/R/gen_objects2stat.R +++ b/R/gen_objects2stat.R @@ -1,15 +1,15 @@ #' Search for Objects Related to a Statistic #' -#' @description Function to find objects related to a statistic in Genesis. +#' @description Function to find objects related to a statistic in GENESIS. #' -#' @param code a string with a maximum length of 6 characters (15 characters if cubes are not used as a category). Code from a Genesis-Object. Only one code per iteration. +#' @param code a string with a maximum length of 6 characters (15 characters if cubes are not used as a category). Code from a GENESIS-Object. Only one code per iteration. #' @param category a string. Specific object-types: 'tables', 'variables', and 'cubes'. All three together are possible and the default option. #' @param detailed a logical. Indicator if function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. The default is detailed = FALSE. -#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. The default is "code". +#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. The default is "code". #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples diff --git a/R/gen_objects2var.R b/R/gen_objects2var.R index 919f2e6..8831632 100644 --- a/R/gen_objects2var.R +++ b/R/gen_objects2var.R @@ -1,15 +1,15 @@ #' Search for Objects Related to a Variable #' -#' @description Function to find objects related to a variable in Genesis. +#' @description Function to find objects related to a variable in GENESIS. #' -#' @param code a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. +#' @param code a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. #' @param category a string. Specific object-types: 'tables', 'statistics', and 'cubes'. All three together are possible and the default option. #' @param detailed a logical. Indicator if function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. The default is detailed = FALSE. -#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. The default is "code". +#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. The default is "code". #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples diff --git a/R/gen_table.R b/R/gen_table.R index faa6953..e0ebae8 100644 --- a/R/gen_table.R +++ b/R/gen_table.R @@ -1,9 +1,9 @@ -#’ Get the Data of a Table From Genesis +#' Get the Data of a Table From GENESIS #' -#' @description Download a table with data from Genesis. +#' @description Download a table with data from GENESIS. #' #' @param name a string. Name of the table. Use of wildcards (`*`) allowed. -#' @param ... Optional parameters passed on to the Genesis API call: +#' @param ... Optional parameters passed on to the GENESIS API call: #' \describe{ #' \item{\code{area}}{a string. The area in which the table is stored. Possible values: #' \itemize{ diff --git a/R/gen_var2-val2.R b/R/gen_var2-val2.R index b2a5f04..96572db 100644 --- a/R/gen_var2-val2.R +++ b/R/gen_var2-val2.R @@ -1,14 +1,14 @@ #' Search for the Variables From a Statistic #' -#' @description Function to generate variables from statistics in Genesis. +#' @description Function to generate variables from statistics in GENESIS. #' -#' @param code a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder. +#' @param code a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder. #' @param detailed a logical. Indicator if function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. The default is detailed = FALSE. -#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. The default is "code". +#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. The default is "code". #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples @@ -89,14 +89,14 @@ gen_var2stat <- function(code = NULL, #' Search for the Values of a Variable #' -#' @description Function to extract the possible values from a variable from Genesis. Values for continuous variables are not extractable, so the function returns a warning message. +#' @description Function to extract the possible values from a variable from GENESIS. Values for continuous variables are not extractable, so the function returns a warning message. #' -#' @param code a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. -#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. The default is "code". +#' @param code a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. +#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. The default is "code". #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples @@ -164,15 +164,15 @@ gen_val2var <- function(code = NULL, #' Search for the Variables and Their Values From a Statistic #' -#' @description Function to extract the possible values from a variable from a statistic in Genesis. Values for continuous variables are not extractable, so the function returns a warning message. +#' @description Function to extract the possible values from a variable from a statistic in GENESIS. Values for continuous variables are not extractable, so the function returns a warning message. #' -#' @param code a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder. +#' @param code a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder. #' @param detailed a logical. Indicator if function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. This parameter only affects the details of the variables-related output. The default is FALSE. #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is an parameter of the Genesis API call itself. The default is "code". -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself for the variables, no further processing for the values-related objects. +#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is an parameter of the GENESIS API call itself. The default is "code". +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself for the variables, no further processing for the values-related objects. #' -#' @return A list with all recalled elements from Genesis. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples @@ -226,19 +226,19 @@ gen_val2var2stat <- function(code = NULL, #' Search for a Specific Variable #' -#' @description Function to search for specific variables in Genesis. +#' @description Function to search for specific variables in GENESIS. #' -#' @param code a string with a maximum length of 6. Code from a Genesis-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder. -#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. The default is "code". +#' @param code a string with a maximum length of 6. Code from a GENESIS-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder. +#' @param sortcriterion a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. The default is "code". #' @param error.ignore a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. -#' @param ... Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing. +#' @param ... Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing. #' -#' @return A list with all recalled elements from Genesis. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +#' @return A list with all recalled elements from GENESIS. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. #' @export #' #' @examples #' \dontrun{ -#' # Find a specific variable "GES" in Genesis +#' # Find a specific variable "GES" in GENESIS #' object <- gen_search_vars("GES") #' } #' diff --git a/R/restatis-package.R b/R/restatis-package.R new file mode 100644 index 0000000..a65cf64 --- /dev/null +++ b/R/restatis-package.R @@ -0,0 +1,6 @@ +#' @keywords internal +"_PACKAGE" + +## usethis namespace: start +## usethis namespace: end +NULL diff --git a/man/evas_list_long_20220724.Rd b/man/evas_list_long_20220724.Rd index fcf3a84..fbf734b 100644 --- a/man/evas_list_long_20220724.Rd +++ b/man/evas_list_long_20220724.Rd @@ -3,7 +3,7 @@ \docType{data} \name{evas_list_long_20220724} \alias{evas_list_long_20220724} -\title{List of EVAS codes} +\title{List of EVAS Codes} \format{ \subsection{\code{evas_list_long_20220724}}{ @@ -23,6 +23,6 @@ A data frame with 1,097 rows and 3 columns: evas_list_long_20220724 } \description{ -List of EVAS codes +List of EVAS Codes } \keyword{datasets} diff --git a/man/gen_alternative_terms.Rd b/man/gen_alternative_terms.Rd index 9c62d18..894c444 100644 --- a/man/gen_alternative_terms.Rd +++ b/man/gen_alternative_terms.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_alternative_terms.R \name{gen_alternative_terms} \alias{gen_alternative_terms} -\title{gen_alternative_terms: Call for similar or spelling related terms for further search} +\title{Search for Related Terms Based on the Same Specific String} \usage{ gen_alternative_terms(term = NULL, similarity = TRUE, ...) } @@ -11,13 +11,13 @@ gen_alternative_terms(term = NULL, similarity = TRUE, ...) \item{similarity}{Logical. Indicator if the output of the function should be sorted based on a Levenshtein edit distance based on the \code{adist()} function.} -\item{...}{Additional parameters for the Genesis API call. These parameters are only affecting the Genesis call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Attributes are added to the data.frame, describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Attributes are added to the data.frame, describing the search configuration for the returned output. } \description{ -Function to find search terms that are similar or related to one another and also represented in Genesis. +Function to find terms in GENESIS that are similar or related based on a simple comparison of strings. This can help to identify alternative search terms. } \examples{ \dontrun{ diff --git a/man/gen_auth_save.Rd b/man/gen_auth_save.Rd index 96b3a04..5996373 100644 --- a/man/gen_auth_save.Rd +++ b/man/gen_auth_save.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_auth.R \name{gen_auth_save} \alias{gen_auth_save} -\title{Save authentication} +\title{Save Authentication of Your GENESIS Account} \usage{ gen_auth_save() } @@ -13,12 +13,12 @@ Path to the RDS file in which credentials are saved, invisibly. See Details. } \details{ -Genesis username and password are encrypted and saved as RDS in the +GENESIS username and password are encrypted and saved as RDS in the package config directory. A random string is generated and stored in the session environment variable \code{RESTATIS_KEY}. This string is used as the key to encrypt and -decrypt the entered Genesis credentials. +decrypt the entered GENESIS credentials. To avoid having to save authentication in future sessions, \code{RESTATIS_KEY} can be added to .Renviron. The usethis package includes a helper function for diff --git a/man/gen_catalogue.Rd b/man/gen_catalogue.Rd index b2d6026..ce328e4 100644 --- a/man/gen_catalogue.Rd +++ b/man/gen_catalogue.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_catalogue.R \name{gen_catalogue} \alias{gen_catalogue} -\title{catalogue: Explore Different Objects and Their Structural Embedding in Genesis} +\title{Explore Different Objects and Their Structural Embedding in GENESIS} \usage{ gen_catalogue( code = NULL, @@ -14,23 +14,23 @@ gen_catalogue( ) } \arguments{ -\item{code}{a string with a maximum length of 10 characters. Code from a Genesis-Object. Only one code per iteration. "*"-Notations are possible.} +\item{code}{a string with a maximum length of 10 characters. Code from a GENESIS-Object. Only one code per iteration. "*"-Notations are possible.} -\item{category}{a string. Specific Genesis-Object-types: 'tables', 'statistics', and 'cubes'. All three together are possible.} +\item{category}{a string. Specific GENESIS-Object-types: 'tables', 'statistics', and 'cubes'. All three together are possible.} \item{detailed}{a logical. Indicator if the function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title.} -\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself.} +\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself.} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis API. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS API. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ -Function to enable searching for tables, statistics, and cubes from Genesis. Additionally, it structures the output based on the internal tree structure of Genesis itself based on the EVAS-numbers. Time-series are represented as cubes with a specified time span. +Function to enable searching for tables, statistics, and cubes from GENESIS. Additionally, it structures the output based on the internal tree structure of GENESIS itself based on the EVAS-numbers. Time-series are represented as cubes with a specified time span. } \examples{ \dontrun{ diff --git a/man/gen_cube.Rd b/man/gen_cube.Rd index 7c1361e..45e28b7 100644 --- a/man/gen_cube.Rd +++ b/man/gen_cube.Rd @@ -2,14 +2,14 @@ % Please edit documentation in R/gen_cube.R \name{gen_cube} \alias{gen_cube} -\title{gen_cube} +\title{Get the Data of a Cube From GENESIS} \usage{ gen_cube(name, ...) } \arguments{ \item{name}{Name of the data cube} -\item{...}{Optional parameters passed on to the Genesis API call: +\item{...}{Optional parameters passed on to the GENESIS API call: \describe{ \item{\code{area}}{a string. The area in which the table is stored. Possible values: \itemize{ @@ -47,7 +47,7 @@ A \link[tibble:tibble]{tibble}. Non-data contents of the data cube object are sa the \code{metadata} \link[base:attr]{attribute} of the data frame. } \description{ -Download a cube with data from Genesis +Download a cube with data from GENESIS. } \examples{ \dontrun{ diff --git a/man/gen_find.Rd b/man/gen_find.Rd index 7d478dd..4510314 100644 --- a/man/gen_find.Rd +++ b/man/gen_find.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_find.R \name{gen_find} \alias{gen_find} -\title{gen_find} +\title{General Search for Objects Through GENESIS} \usage{ gen_find( term = NULL, @@ -24,28 +24,28 @@ gen_find( \item{error.ignore}{A logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce an artificial response (e.g., for complex processes not to fail).} -\item{...}{Additional parameters of the Genesis API call. These parameters are only affecting the Genesis API call itself, there is no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all elements retrieved from Genesis. Attributes are added to the data.frame describing the search configuration for the returned output. +A list with all elements retrieved from GENESIS. Attributes are added to the data.frame describing the search configuration for the returned output. } \description{ -Function to search through Genesis. It is similar in usage as the search function on the Destatis main page (https://www.destatis.de/DE/Home/_inhalt.html). +Function to search through GENESIS. It is similar in usage as the search function on the Destatis main page (https://www.destatis.de/DE/Home/_inhalt.html). In the search query, "UND" (german word for: and; can also be written "und" or "&") as well as "ODER" (german word for: or; can also be written "oder" or "|") can be included and logically combined. Furthermore, wildcards are possible by including "*". If more then one word is included in the term-string, automatically "and" is used to combine the different words. Important note: Time-series are treated as cubes, they are not longer distinguished. If you want to find a specific object with a clear code with this find function, you need to specify the object type or search for all object types. } \examples{ \dontrun{ -# Find objects related to "bus" in Genesis +# Find objects related to "bus" in GENESIS object <- gen_find(term = "bus") -# Find tables related to "bus" in Genesis and return a unordered detailed output +# Find tables related to "bus" in GENESIS and return a unordered detailed output object <- gen_find(term = "bus", detailed = TRUE, ordering = FALSE) -# Find tables related to "Autos" or "Corona" in Genesis and return a unordered detailed output +# Find tables related to "Autos" or "Corona" in GENESIS and return a unordered detailed output object <- gen_find(term = "autos ODER corona", detailed = TRUE, ordering = FALSE) -#' # Find tables related to "Autos" and "Corona" in Genesis and return a unordered detailed output +#' # Find tables related to "Autos" and "Corona" in GENESIS and return a unordered detailed output object <- gen_find(term = "autos UND corona", detailed = TRUE, ordering = FALSE) } diff --git a/man/gen_list_jobs.Rd b/man/gen_list_jobs.Rd index 69eead8..0254203 100644 --- a/man/gen_list_jobs.Rd +++ b/man/gen_list_jobs.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_list_jobs.R \name{gen_list_jobs} \alias{gen_list_jobs} -\title{gen_list_jobs: Explore current jobs of your user account} +\title{Search for Current Jobs of Your User Account} \usage{ gen_list_jobs( selection = NULL, @@ -15,7 +15,7 @@ gen_list_jobs( \item{sortcriterion}{Allows to sort the resulting list of jobs by their Code ("content"), the time of completion ("time") or status ("status")} -\item{...}{Further parameters to be passed down to the API caller.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ A list of all current jobs connected to the given user. diff --git a/man/gen_metadata.Rd b/man/gen_metadata.Rd index 312ceb5..4fa6093 100644 --- a/man/gen_metadata.Rd +++ b/man/gen_metadata.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_meta_data.R \name{gen_metadata} \alias{gen_metadata} -\title{gen_metadata} +\title{Search for Meta-Information for All Types of Objects} \usage{ gen_metadata( code = NULL, @@ -12,19 +12,19 @@ gen_metadata( ) } \arguments{ -\item{code}{string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration.} +\item{code}{string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration.} \item{category}{a string. Specific object-types: 'Cube', 'Statistic', "Table", "Variable" and 'Value'. The function needs a specified object type.} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ -Search For Meta-Information For All Types Of Objects +Function to search for meta-information for all types of objects. } \examples{ \dontrun{ diff --git a/man/gen_metadata_cube.Rd b/man/gen_metadata_cube.Rd index 3dc1323..f7b1b04 100644 --- a/man/gen_metadata_cube.Rd +++ b/man/gen_metadata_cube.Rd @@ -2,19 +2,19 @@ % Please edit documentation in R/gen_meta_data.R \name{gen_metadata_cube} \alias{gen_metadata_cube} -\title{gen_metadata_cube} +\title{Search for Meta-Information for a Cube} \usage{ gen_metadata_cube(code = NULL, error.ignore = FALSE, ...) } \arguments{ -\item{code}{a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration.} +\item{code}{a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration.} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ Function to search for meta-information for a specific cube. diff --git a/man/gen_metadata_stats.Rd b/man/gen_metadata_stats.Rd index 22102f3..2d3af45 100644 --- a/man/gen_metadata_stats.Rd +++ b/man/gen_metadata_stats.Rd @@ -2,19 +2,19 @@ % Please edit documentation in R/gen_meta_data.R \name{gen_metadata_stats} \alias{gen_metadata_stats} -\title{gen_metadata_stat} +\title{Search for Meta-Information for a Statistic} \usage{ gen_metadata_stats(code = NULL, error.ignore = FALSE, ...) } \arguments{ -\item{code}{a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration.} +\item{code}{a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration.} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ Function to search for meta-information for a specific statistic. diff --git a/man/gen_metadata_tab.Rd b/man/gen_metadata_tab.Rd index ec407a5..f9341e3 100644 --- a/man/gen_metadata_tab.Rd +++ b/man/gen_metadata_tab.Rd @@ -2,19 +2,19 @@ % Please edit documentation in R/gen_meta_data.R \name{gen_metadata_tab} \alias{gen_metadata_tab} -\title{gen_metadata_tab} +\title{Search for Meta-Information for a Table} \usage{ gen_metadata_tab(code = NULL, error.ignore = FALSE, ...) } \arguments{ -\item{code}{a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration.} +\item{code}{a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration.} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ Function to search for meta-information for a specific table. diff --git a/man/gen_metadata_val.Rd b/man/gen_metadata_val.Rd index 3693bc8..46bc28e 100644 --- a/man/gen_metadata_val.Rd +++ b/man/gen_metadata_val.Rd @@ -2,19 +2,19 @@ % Please edit documentation in R/gen_meta_data.R \name{gen_metadata_val} \alias{gen_metadata_val} -\title{gen_metadata_val} +\title{Search for Meta-Information for a Value} \usage{ gen_metadata_val(code = NULL, error.ignore = FALSE, ...) } \arguments{ -\item{code}{a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration.} +\item{code}{a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration.} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ Function to search for meta-information for a specific value. diff --git a/man/gen_metadata_var.Rd b/man/gen_metadata_var.Rd index a80dfbf..a393cfc 100644 --- a/man/gen_metadata_var.Rd +++ b/man/gen_metadata_var.Rd @@ -2,19 +2,19 @@ % Please edit documentation in R/gen_meta_data.R \name{gen_metadata_var} \alias{gen_metadata_var} -\title{gen_metadata_var} +\title{Search for Meta-Information for a Variable} \usage{ gen_metadata_var(code = NULL, error.ignore = FALSE, ...) } \arguments{ -\item{code}{a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. "*"-Notation is possible.} +\item{code}{a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. "*"-Notation is possible.} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ Function to search for meta-information for a specific variable. diff --git a/man/gen_modified_data.Rd b/man/gen_modified_data.Rd index 4a57f8e..37e2c66 100644 --- a/man/gen_modified_data.Rd +++ b/man/gen_modified_data.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_modified_data.R \name{gen_modified_data} \alias{gen_modified_data} -\title{gen_modified_data: Explore New Added Objects or Changed Objects in Genesis} +\title{Search for Newly Added Objects or Documented Changes to Objects in GENESIS} \usage{ gen_modified_data( code = "", @@ -12,19 +12,19 @@ gen_modified_data( ) } \arguments{ -\item{code}{a string with a maximum length of 15 characters. Code from a Genesis object. Only one code per iteration. "*" notations are possible. Empty code (default value) includes all changes, updates, and new added objects.} +\item{code}{a string with a maximum length of 15 characters. Code from a GENESIS object. Only one code per iteration. "*" notations are possible. Empty code (default value) includes all changes, updates, and new added objects.} -\item{type}{a string. Specific Genesis object type: 'tables', 'statistics', and 'statisticsUpdates'. All three can be accessed through "all", which is the default.} +\item{type}{a string. Specific GENESIS object type: 'tables', 'statistics', and 'statisticsUpdates'. All three can be accessed through "all", which is the default.} -\item{date}{a string. Specific date that is used as the last update or upload time in Genesis to include a Genesis object in return. Default option is 'now', which uses the current date of your system. Alternative options are 'week_before', using the current date of your system minus 7 days, 'month_before', using the current date of your system minus 4 weeks, and 'year_before', using the current date of your system minus 52 weeks. Additionally, it is possible to fill in a specific date of format 'DD.MM.YYYY'.} +\item{date}{a string. Specific date that is used as the last update or upload time in GENESIS to include a GENESIS object in return. Default option is 'now', which uses the current date of your system. Alternative options are 'week_before', using the current date of your system minus 7 days, 'month_before', using the current date of your system minus 4 weeks, and 'year_before', using the current date of your system minus 52 weeks. Additionally, it is possible to fill in a specific date of format 'DD.MM.YYYY'.} -\item{...}{Additional parameters for the Genesis call. These parameters are only affecting the Genesis call itself, not the further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output. } \description{ -Function to check for updates, changes, or new objects in Genesis based on a specific date. +Function to check for updates, changes, or new objects in GENESIS based on a specific date. } \examples{ \dontrun{ diff --git a/man/gen_objects2stat.Rd b/man/gen_objects2stat.Rd index 41ce8e9..39e7e6a 100644 --- a/man/gen_objects2stat.Rd +++ b/man/gen_objects2stat.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_objects2stat.R \name{gen_objects2stat} \alias{gen_objects2stat} -\title{gen_objects2stat: Get Objects Related To Statistics} +\title{Search for Objects Related to a Statistic} \usage{ gen_objects2stat( code = NULL, @@ -14,28 +14,28 @@ gen_objects2stat( ) } \arguments{ -\item{code}{a string with a maximum length of 6 characters (15 characters if cubes are not used as a category). Code from a Genesis-Object. Only one code per iteration.} +\item{code}{a string with a maximum length of 6 characters (15 characters if cubes are not used as a category). Code from a GENESIS-Object. Only one code per iteration.} \item{category}{a string. Specific object-types: 'tables', 'variables', and 'cubes'. All three together are possible and the default option.} \item{detailed}{a logical. Indicator if function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. The default is detailed = FALSE.} -\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. The default is "code".} +\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. The default is "code".} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ -Function to find objects related to a statistic in Genesis. +Function to find objects related to a statistic in GENESIS. } \examples{ \dontrun{ # Find cubes from the statistic with the code "21111" with a detailed return - object <- gen_objects2stat(code = "21111", category = "cubes", detailed = T) +object <- gen_objects2stat(code = "21111", category = "cubes", detailed = T) # Find all object types from the statistic with the code "12411" object <- gen_objects2stat(code = "12411") diff --git a/man/gen_objects2var.Rd b/man/gen_objects2var.Rd index 03e4f25..f140cbf 100644 --- a/man/gen_objects2var.Rd +++ b/man/gen_objects2var.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_objects2var.R \name{gen_objects2var} \alias{gen_objects2var} -\title{gen_objects2var: Get Objects Related To Variable} +\title{Search for Objects Related to a Variable} \usage{ gen_objects2var( code = NULL, @@ -14,23 +14,23 @@ gen_objects2var( ) } \arguments{ -\item{code}{a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration.} +\item{code}{a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration.} \item{category}{a string. Specific object-types: 'tables', 'statistics', and 'cubes'. All three together are possible and the default option.} \item{detailed}{a logical. Indicator if function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. The default is detailed = FALSE.} -\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. The default is "code".} +\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. The default is "code".} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ -Function to find objects related to a variable in Genesis. +Function to find objects related to a variable in GENESIS. } \examples{ \dontrun{ diff --git a/man/gen_search_vars.Rd b/man/gen_search_vars.Rd index 4eef068..b9ad2f0 100644 --- a/man/gen_search_vars.Rd +++ b/man/gen_search_vars.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_var2-val2.R \name{gen_search_vars} \alias{gen_search_vars} -\title{gen_search_vars: Search for Specific Variables} +\title{Search for a Specific Variable} \usage{ gen_search_vars( code = NULL, @@ -12,23 +12,23 @@ gen_search_vars( ) } \arguments{ -\item{code}{a string with a maximum length of 6. Code from a Genesis-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder.} +\item{code}{a string with a maximum length of 6. Code from a GENESIS-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder.} -\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. The default is "code".} +\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. The default is "code".} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ -Function to search for specific variables in Genesis. +Function to search for specific variables in GENESIS. } \examples{ \dontrun{ -# Find a specific variable "GES" in Genesis +# Find a specific variable "GES" in GENESIS object <- gen_search_vars("GES") } diff --git a/man/gen_table.Rd b/man/gen_table.Rd index dbb99ca..745a229 100644 --- a/man/gen_table.Rd +++ b/man/gen_table.Rd @@ -2,14 +2,14 @@ % Please edit documentation in R/gen_table.R \name{gen_table} \alias{gen_table} -\title{gen_table} +\title{Get the Data of a Table From GENESIS} \usage{ gen_table(name, ...) } \arguments{ \item{name}{a string. Name of the table. Use of wildcards (\code{*}) allowed.} -\item{...}{Optional parameters passed on to the Genesis API call: +\item{...}{Optional parameters passed on to the GENESIS API call: \describe{ \item{\code{area}}{a string. The area in which the table is stored. Possible values: \itemize{ @@ -44,7 +44,7 @@ descriptions in German (\code{"de"}) or English (\code{"en"})?} A \link[tibble:tibble]{tibble}. } \description{ -Download a table with data from Genesis +Download a table with data from GENESIS. } \examples{ \dontrun{ diff --git a/man/gen_val2var.Rd b/man/gen_val2var.Rd index ee3f44e..f7ad1bd 100644 --- a/man/gen_val2var.Rd +++ b/man/gen_val2var.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_var2-val2.R \name{gen_val2var} \alias{gen_val2var} -\title{gen_val2var: Get Values From a Variable} +\title{Search for the Values of a Variable} \usage{ gen_val2var( code = NULL, @@ -12,19 +12,19 @@ gen_val2var( ) } \arguments{ -\item{code}{a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration.} +\item{code}{a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration.} -\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. The default is "code".} +\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. The default is "code".} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ -Function to extract the possible values from a variable from Genesis. Values for continuous variables are not extractable, so the function returns a warning message. +Function to extract the possible values from a variable from GENESIS. Values for continuous variables are not extractable, so the function returns a warning message. } \examples{ \dontrun{ diff --git a/man/gen_val2var2stat.Rd b/man/gen_val2var2stat.Rd index 7775583..0f36d6a 100644 --- a/man/gen_val2var2stat.Rd +++ b/man/gen_val2var2stat.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_var2-val2.R \name{gen_val2var2stat} \alias{gen_val2var2stat} -\title{gen_val2var2stat: Get Values From a Variable From a Statistic} +\title{Search for the Variables and Their Values From a Statistic} \usage{ gen_val2var2stat( code = NULL, @@ -13,21 +13,21 @@ gen_val2var2stat( ) } \arguments{ -\item{code}{a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder.} +\item{code}{a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder.} \item{detailed}{a logical. Indicator if function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. This parameter only affects the details of the variables-related output. The default is FALSE.} -\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is an parameter of the Genesis API call itself. The default is "code".} +\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is an parameter of the GENESIS API call itself. The default is "code".} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself for the variables, no further processing or the values-related objects.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself for the variables, no further processing for the values-related objects.} } \value{ -A list with all recalled elements from Genesis. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ -Get values from variables from a statistic. Values for continuous variables cannot be extracted, so the function returns a warning message. +Function to extract the possible values from a variable from a statistic in GENESIS. Values for continuous variables are not extractable, so the function returns a warning message. } \examples{ \dontrun{ diff --git a/man/gen_var2stat.Rd b/man/gen_var2stat.Rd index 67b0951..446b2e0 100644 --- a/man/gen_var2stat.Rd +++ b/man/gen_var2stat.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gen_var2-val2.R \name{gen_var2stat} \alias{gen_var2stat} -\title{gen_var2stat: Get Variables From a Statistic} +\title{Search for the Variables From a Statistic} \usage{ gen_var2stat( code = NULL, @@ -13,21 +13,21 @@ gen_var2stat( ) } \arguments{ -\item{code}{a string with a maximum length of 15 characters. Code from a Genesis-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder.} +\item{code}{a string with a maximum length of 15 characters. Code from a GENESIS-Object. Only one code per iteration. "*"-Notations are possibly to be used as a placeholder.} \item{detailed}{a logical. Indicator if function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. The default is detailed = FALSE.} -\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the Genesis API call itself. The default is "code".} +\item{sortcriterion}{a string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the GENESIS API call itself. The default is "code".} \item{error.ignore}{a logical. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response.} -\item{...}{Additional parameter of the Genesis API call. These parameters are only affecting the Genesis API call itself, no further processing.} +\item{...}{Additional parameter of the GENESIS API call. These parameters are only affecting the GENESIS API call itself, no further processing.} } \value{ -A list with all recalled elements from Genesis. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. +A list with all recalled elements from GENESIS. Based on the detailed-parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing of the data. Attributes are added to the dataframe describing the search configuration for the returned output. } \description{ -Function to generate variables from statistics in Genesis. +Function to generate variables from statistics in GENESIS. } \examples{ \dontrun{ diff --git a/man/restatis-package.Rd b/man/restatis-package.Rd new file mode 100644 index 0000000..e7d2e1c --- /dev/null +++ b/man/restatis-package.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/restatis-package.R +\docType{package} +\name{restatis-package} +\alias{restatis} +\alias{restatis-package} +\title{restatis: API Client for the German Federal Statistical Office Database} +\description{ +A RESTful API wrapper for accessing the GENESIS database of the German Federal Statistical Office (Destatis) \url{https://www-genesis.destatis.de/}. Also supports data search functions, credential management, result caching, and handling remote background jobs for large datasets. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://correlaid.github.io/restatis/} + \item \url{https://github.com/CorrelAid/restatis} + \item Report bugs at \url{https://github.com/CorrelAid/restatis/issues} +} + +} +\author{ +\strong{Maintainer}: Long Nguyen \email{long.nguyen@uni-bielefeld.de} (\href{https://orcid.org/0000-0001-8878-7386}{ORCID}) + +Authors: +\itemize{ + \item Yannik Buhl \email{yannik.buhl@posteo.de} + \item Zoran Kovacevic \email{zoran.kovacevic@gess.ethz.ch} (\href{https://orcid.org/0009-0002-0156-0862}{ORCID}) + \item Dorian Le Jeune \email{d.le-jeune@gmx.de} + \item Johannes Ritter \email{ritter.johannes@gmail.com} +} + +} +\keyword{internal} From e4b477312427801d3b3cf03fdce906e6c1163b14 Mon Sep 17 00:00:00 2001 From: "long.nguyen" Date: Tue, 27 Jun 2023 11:32:22 +0200 Subject: [PATCH 6/8] CRAN resubmission --- DESCRIPTION | 26 ++++++++++++++------------ R/gen_auth.R | 3 ++- cran-comments.md | 22 ++++++++++++++++++++++ man/restatis-package.Rd | 4 ++-- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6ef7322..4415a79 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,22 +1,23 @@ Package: restatis -Title: R Wrapper for the GENESIS Web Service RESTful API of the German - Federal Statistical Office (Statistisches Bundesamt/Destatis) +Title: Web API Client for the German Federal Statistical Office Database Version: 0.1.0 Authors@R: c( - person("Yannik", "Buhl", role = "aut"), - person("Zoran", "Kovacevic", role = "aut", + person("Yannik", "Buhl", , "yannik.buhl@posteo.de", role = "aut"), + person("Zoran", "Kovacevic", , "zoran.kovacevic@gess.ethz.ch", role = "aut", comment = c(ORCID = "0009-0002-0156-0862")), - person("Dorian", "Le Jeune", role = "aut"), + person("Dorian", "Le Jeune", , "d.le-jeune@gmx.de", role = "aut"), person("Long", "Nguyen", , "long.nguyen@uni-bielefeld.de", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-8878-7386")), - person("Johannes", "Ritter", role = "aut") + person("Johannes", "Ritter", , "ritter.johannes@gmail.com", role = "aut") ) -Description: A RESTful API wrapper for accessing the GENESIS database of - the German Federal Statistical Office (Destatis). Also supports data - search functions, credential management, result caching, and handling - remote background jobs for large datasets. +Description: A 'RESTful' API wrapper for accessing the 'GENESIS' database + of the German Federal Statistical Office (Destatis) + . Also supports data search + functions, credential management, result caching, and handling remote + background jobs for large datasets. License: MIT + file LICENSE -URL: https://correlaid.github.io/restatis/, https://github.com/CorrelAid/restatis +URL: https://correlaid.github.io/restatis/, + https://github.com/CorrelAid/restatis BugReports: https://github.com/CorrelAid/restatis/issues Depends: R (>= 2.10) @@ -35,7 +36,8 @@ Suggests: knitr, rmarkdown, testthat (>= 3.0.0), - usethis + usethis, + withr VignetteBuilder: knitr Config/testthat/edition: 3 diff --git a/R/gen_auth.R b/R/gen_auth.R index 0e6fdc0..50f736e 100644 --- a/R/gen_auth.R +++ b/R/gen_auth.R @@ -74,5 +74,6 @@ gen_auth_ask <- function(credential_type) { } gen_auth_path <- function(...) { - file.path(tools::R_user_dir("restatis", "config"), ...) + path <- getOption("restatis:::config_dir", tools::R_user_dir("restatis", "config")) + file.path(path, ...) } diff --git a/cran-comments.md b/cran-comments.md index 858617d..0cb6713 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,25 @@ +## Resubmission + +### Documentation issues + +> Please reduce the length of the title to less than 65 characters. + +> Please always write package names, software names and API (application programming interface) names in single quotes in title and description. +> e.g: --> 'RESTful' +> Please note that package names are case sensitive. + +> Please add a web reference for the API in the form to the description of the DESCRIPTION file with no space after 'https:' and angle brackets for auto-linking. + +These have all been fixed. + +### Credential storage + +> Please ensure that your functions do not write by default or in your examples/vignettes/tests in the user's home filespace (including the package directory and getwd()). This is not allowed by CRAN policies. Please omit any default path in writing functions. In your examples/vignettes/tests you can write to tempdir(). -> R/gen_auth.R + +We are not sure we fully understand this. Is writing in the user's home generally not allowed in function bodies, or only in tests? (Examples and vignettes are skipped/manually pre-rendered and thus not affected.) + +If the latter, we have changed `gen_auth_path()` to use a private option `restatis:::config_dir`, which can be set to `tempdir()` in tests. This is the same approach used by the rtweet package ([implementation](https://github.com/ropensci/rtweet/blob/4d42cc8b1d5f4c445bb5865181485423c265f3ed/R/auth.R#L408), [test](https://github.com/ropensci/rtweet/blob/4d42cc8b1d5f4c445bb5865181485423c265f3ed/tests/testthat/test-auth.R#L16)). Currently, we do not test authentication, and testing of API responses is done using [mock files](https://enpiar.com/httptest2/reference/with_mock_dir.html), so the tests are not affected by this option. + ## R CMD check results 0 errors | 0 warnings | 1 note diff --git a/man/restatis-package.Rd b/man/restatis-package.Rd index e7d2e1c..37fd6b9 100644 --- a/man/restatis-package.Rd +++ b/man/restatis-package.Rd @@ -4,9 +4,9 @@ \name{restatis-package} \alias{restatis} \alias{restatis-package} -\title{restatis: API Client for the German Federal Statistical Office Database} +\title{restatis: Web API Client for the German Federal Statistical Office Database} \description{ -A RESTful API wrapper for accessing the GENESIS database of the German Federal Statistical Office (Destatis) \url{https://www-genesis.destatis.de/}. Also supports data search functions, credential management, result caching, and handling remote background jobs for large datasets. +A 'RESTful' API wrapper for accessing the 'GENESIS' database of the German Federal Statistical Office (Destatis) \url{https://www-genesis.destatis.de/}. Also supports data search functions, credential management, result caching, and handling remote background jobs for large datasets. } \seealso{ Useful links: From 9f2d581e2c8ce67e23d4f42ea00e8135d1a9fb6c Mon Sep 17 00:00:00 2001 From: "long.nguyen" Date: Wed, 28 Jun 2023 12:05:14 +0200 Subject: [PATCH 7/8] CRAN resubmission [skip ci] --- CRAN-SUBMISSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 081ce5a..31ff35e 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ Version: 0.1.0 -Date: 2023-06-25 21:06:13 UTC -SHA: dd904701d8e2e3f9a435484b2a84f30b0ad8b889 +Date: 2023-06-28 10:04:36 UTC +SHA: e4b477312427801d3b3cf03fdce906e6c1163b14 From 4ec7d47fe0b3c7bb9b9f5bd89b72f59edf2bce56 Mon Sep 17 00:00:00 2001 From: "long.nguyen" Date: Wed, 28 Jun 2023 12:12:09 +0200 Subject: [PATCH 8/8] Update CRAN comments [skip ci] --- cran-comments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cran-comments.md b/cran-comments.md index 0cb6713..86c763b 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -18,7 +18,7 @@ These have all been fixed. We are not sure we fully understand this. Is writing in the user's home generally not allowed in function bodies, or only in tests? (Examples and vignettes are skipped/manually pre-rendered and thus not affected.) -If the latter, we have changed `gen_auth_path()` to use a private option `restatis:::config_dir`, which can be set to `tempdir()` in tests. This is the same approach used by the rtweet package ([implementation](https://github.com/ropensci/rtweet/blob/4d42cc8b1d5f4c445bb5865181485423c265f3ed/R/auth.R#L408), [test](https://github.com/ropensci/rtweet/blob/4d42cc8b1d5f4c445bb5865181485423c265f3ed/tests/testthat/test-auth.R#L16)). Currently, we do not test authentication, and testing of API responses is done using [mock files](https://enpiar.com/httptest2/reference/with_mock_dir.html), so the tests are not affected by this option. +If the latter, we have changed `gen_auth_path()` to use a private option `restatis:::config_dir`, which can be set to `tempdir()` in tests. This is the same approach used by the rtweet package ([implementation](https://github.com/ropensci/rtweet/blob/4d42cc8b1d5f4c445bb5865181485423c265f3ed/R/auth.R#L408), [test](https://github.com/ropensci/rtweet/blob/4d42cc8b1d5f4c445bb5865181485423c265f3ed/tests/testthat/test-auth.R#L16)). Currently, we do not test authentication, and testing of API responses is done using [mock files](https://enpiar.com/httptest2/reference/with_mock_dir.html), so no credentials are written in the tests and the tests are not affected by this option. ## R CMD check results