Skip to content

Commit

Permalink
Update character parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Jul 30, 2024
1 parent 6825d04 commit cc2ee8e
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 214 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Suggests:
VignetteBuilder:
knitr
Config/Needs/coverage: covr
Config/Needs/website: reactable, styler, tidyverse,
ropenspain/rostemplate, devtools, cpp11, remotes
Config/Needs/website: cpp11, devtools, progress, reactable, remotes,
styler, tidyverse, ropenspain/rostemplate
Config/testthat/edition: 3
Config/testthat/parallel: true
Copyright: See file inst/COPYRIGHTS
Expand Down
21 changes: 7 additions & 14 deletions R/catalogs.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bde_catalog_load <- function(catalog = c("ALL", "BE", "SI", "TC", "TI", "PB"),
catalog_load <- read.csv2(catalog_file,
sep = ",",
stringsAsFactors = FALSE, na.strings = "",
header = FALSE
header = FALSE, fileEncoding = "latin1"
)

# Convert names
Expand Down Expand Up @@ -263,13 +263,9 @@ bde_catalog_update <- function(catalog = c("ALL", "BE", "SI", "TC", "TI", "PB"),
}
# nocov end


# Get cache dir
cache_dir <- bde_hlp_cachedir(cache_dir = cache_dir, verbose = verbose)




# Loop and download
catalog_download <- catalog
if ("ALL" %in% catalog) {
Expand All @@ -296,8 +292,7 @@ bde_catalog_update <- function(catalog = c("ALL", "BE", "SI", "TC", "TI", "PB"),

# Download
result <- bde_hlp_download(
url = full_url,
local_file = local_file,
url = full_url, local_file = local_file,
verbose = verbose
)
return(result)
Expand Down Expand Up @@ -376,13 +371,11 @@ bde_catalog_search <- function(pattern, ...) {
search_match_rows <- NULL
# Loop thorugh cols
for (i in col_ind) {
search_match_rows <- unique(c(
search_match_rows,
grep(pattern, catalog_search[[i]],
ignore.case = TRUE,
useBytes = TRUE
)
))
search_match_rows <- unique(
c(search_match_rows, grep(pattern, catalog_search[[i]],
ignore.case = TRUE, useBytes = TRUE
))
)
}

search_results <- catalog_search[search_match_rows, ]
Expand Down
24 changes: 8 additions & 16 deletions R/indicators.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ bde_ind_unemployment_rate <-
function(series_label = "Unemployment_Rate", ...) {
seq_num <- 4635980

econom_ind <-
bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- econom_ind[!is.na(econom_ind[[2]]), ]

return(econom_ind)
Expand All @@ -62,8 +61,7 @@ bde_ind_euribor_12m_monthly <-
...) {
seq_num <- 587853

econom_ind <-
bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- econom_ind[!is.na(econom_ind[[2]]), ]

return(econom_ind)
Expand All @@ -76,8 +74,7 @@ bde_ind_euribor_12m_daily <-
function(series_label = "Euribor_12M_Daily", ...) {
seq_num <- 905842

econom_ind <-
bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- econom_ind[!is.na(econom_ind[[2]]), ]

return(econom_ind)
Expand All @@ -90,8 +87,7 @@ bde_ind_cpi_var <-
function(series_label = "Consumer_price_index_YoY", ...) {
seq_num <- 4144807

econom_ind <-
bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- econom_ind[!is.na(econom_ind[[2]]), ]

return(econom_ind)
Expand All @@ -103,8 +99,7 @@ bde_ind_cpi_var <-
bde_ind_ibex_monthly <- function(series_label = "IBEX_index_month", ...) {
seq_num <- 254433

econom_ind <-
bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- econom_ind[!is.na(econom_ind[[2]]), ]

return(econom_ind)
Expand All @@ -116,8 +111,7 @@ bde_ind_ibex_monthly <- function(series_label = "IBEX_index_month", ...) {
bde_ind_ibex_daily <- function(series_label = "IBEX_index_day", ...) {
seq_num <- 821340

econom_ind <-
bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- econom_ind[!is.na(econom_ind[[2]]), ]

return(econom_ind)
Expand All @@ -129,8 +123,7 @@ bde_ind_ibex_daily <- function(series_label = "IBEX_index_day", ...) {
bde_ind_gdp_quarterly <- function(series_label = "GDP_quarterly_value", ...) {
seq_num <- 3777060

econom_ind <-
bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- bde_series_load(seq_num, series_label = series_label, ...)
econom_ind <- econom_ind[!is.na(econom_ind[[2]]), ]

return(econom_ind)
Expand All @@ -143,8 +136,7 @@ bde_ind_gdp_quarterly <- function(series_label = "GDP_quarterly_value", ...) {
bde_ind_population <- function(series_label = "Population_Spain", ...) {
# seq_num <- 3078287

Check warning on line 137 in R/indicators.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/indicators.R,line=137,col=5,[commented_code_linter] Commented code should be removed.
#
# econom_ind <-
# bde_series_load(seq_num, series_label = series_label, ...)
# econom_ind <- bde_series_load(seq_num, series_label = series_label, ...)

Check warning on line 139 in R/indicators.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/indicators.R,line=139,col=5,[commented_code_linter] Commented code should be removed.
# econom_ind <- econom_ind[!is.na(econom_ind[[2]]), ]

Check warning on line 140 in R/indicators.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/indicators.R,line=140,col=5,[commented_code_linter] Commented code should be removed.
#
# return(econom_ind)

Check warning on line 142 in R/indicators.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/indicators.R,line=142,col=5,[commented_code_linter] Commented code should be removed.
Expand Down
19 changes: 5 additions & 14 deletions R/scales.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ scale_color_bde_d <- function(
cols_v <- bde_tidy_palettes(palette = palette, alpha = alpha, rev = rev)
pal <- scales::manual_pal(cols_v)

ggplot2::discrete_scale(
aesthetics = "color",
palette = pal,
...
)
ggplot2::discrete_scale(aesthetics = "color", palette = pal, ...)
}

#' @rdname scales_bde
Expand All @@ -81,11 +77,7 @@ scale_fill_bde_d <- function(
cols_v <- bde_tidy_palettes(palette = palette, alpha = alpha, rev = rev)
pal <- scales::manual_pal(cols_v)

ggplot2::discrete_scale(
aesthetics = "fill",
palette = pal,
...
)
ggplot2::discrete_scale(aesthetics = "fill", palette = pal, ...)
}


Expand All @@ -104,8 +96,7 @@ scale_color_bde_c <- function(
rev = rev
),
"bde_qual_pal" = bde_tidy_palettes(6, "bde_qual_pal",
alpha = alpha,
rev = rev
alpha = alpha, rev = rev
),
"bde_rose_pal" = bde_tidy_palettes(6, "bde_rose_pal",
alpha = alpha,
Expand Down Expand Up @@ -149,10 +140,10 @@ scale_fill_bde_c <- function(
rev = rev
)[c(1, 2, 3, 6, 5, 4)]
)

ggplot2::continuous_scale(
aesthetics = "fill",
palette = scales::gradient_n_pal(cols),
guide = guide,
...
guide = guide, ...
)
}
Loading

0 comments on commit cc2ee8e

Please sign in to comment.