diff --git a/R/rdb_dimensions.R b/R/rdb_dimensions.R index 0244b5f7ffe913fd37181209d29bfcb710288764..0727b984a8795c259ed5e7641291c9f2bf824998 100644 --- a/R/rdb_dimensions.R +++ b/R/rdb_dimensions.R @@ -148,6 +148,15 @@ rdb_dimensions <- function( tmp1 <- as.list(tmp1) tmp1 <- data.table::data.table(A = unlist(tmp1), B = names(tmp1)) tmp1 <- unique(tmp1) + # Normally column B is in capital letters + if (nrow(tmp1) > 0) { + tmp1[, EQUAL := as.numeric(A == B)] + tmp1[ + EQUAL == 1, + A := ifelse(A == capital_first(A), toupper(A), capital_first(A)) + ] + tmp1[, EQUAL := NULL] + } } tmp2 <- tmp$datasets$docs$dimensions_values_labels diff --git a/R/rdbnomics.R b/R/rdbnomics.R index f7cd959a3c14628d84e17e80965dd76e35fbbf10..ed875e27a7bdf013fc4c4c14ec87e47a6e3ff614 100644 --- a/R/rdbnomics.R +++ b/R/rdbnomics.R @@ -14,7 +14,7 @@ if (getRversion() >= "2.15.1") { ".", ":=", "value", "dotI", "period", "period_start_day", "series_code", "filtered", "original_period", "series_name", "original_value", "period_middle_day", "code", "name", "A", "B", "C", "k", "V1", "V2", - "dataset_code" + "dataset_code", "EQUAL" ) utils::globalVariables(unique(vars)) } \ No newline at end of file diff --git a/R/utils.R b/R/utils.R index d45a535e25a1a269792e2f31a772382de1d30ba8..fa1052302cb12b203a5f0aa8cde76b45857da9f4 100644 --- a/R/utils.R +++ b/R/utils.R @@ -15,9 +15,12 @@ get_data <- function(x, userl, curl_args, headers = NULL, opt = NULL, run = 0) { tryCatch({ if (userl) { # Only readLines - if (as.numeric(R.Version()$major) >= 3) { + if (as.numeric(R.Version()$major) == 3) { if (as.numeric(R.Version()$minor) < 2) { - suppressMessages(suppressWarnings(utils::setInternet2(TRUE))) + try( + suppressMessages(suppressWarnings(utils::setInternet2(TRUE))), + silent = TRUE + ) } } @@ -589,7 +592,20 @@ get_geo_colname <- function(x) { ref_elt <- gsub(".*\\.", "", z) elt_ <- gsub('\\.', '"]][["', z) elt_ <- paste0('[["', elt_, '"]]') - c(codes[i], ref_elt, eval(parse(text = paste0("x", elt_)))) + + res <- c(codes[i], ref_elt, eval(parse(text = paste0("x", elt_)))) + if (length(res) > 0) { + if (res[2] == res[3]) { + if (res[3] == capital_first(res[3])) { + res[3] <- toupper(res[3]) + } else { + res[3] <- capital_first(res[3]) + } + } + res + } else { + res + } }) }, silent = TRUE