Skip to content

Commit

Permalink
Added portal argument to get_metadata()
Browse files Browse the repository at this point in the history
  • Loading branch information
byrongibby committed Mar 22, 2024
1 parent dd13796 commit d0d26a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions R/get_metadata.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
get_metadata <- function(x) {
env <- fromJSON(system.file("settings.json", package = "econdatar"))
get_metadata <- function(x, ...) {
params <- list(...)
if (!is.null(params$portal)) {
portal <- params$portal
} else {
portal <- "econdata"
}
env <- fromJSON(system.file("settings.json", package = "econdatar"))[[portal]]


# Fetch data structure definition (metadata) ----
Expand Down
4 changes: 2 additions & 2 deletions R/tidy_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tidy_wide <- function(x, codelabel = FALSE, prettymeta = TRUE, ...) {
tidy_wide,
codelabel,
prettymeta))
metadata <- if (prettymeta) get_metadata(x) else NULL
metadata <- if (prettymeta) get_metadata(x, ...) else NULL
d <- unlist2d(x, "series_key", row.names = "time_period", DT = TRUE) |>
dcast(time_period ~ series_key, value.var = "OBS_VALUE") |>
fmutate(time_period = as.Date(time_period))
Expand Down Expand Up @@ -86,7 +86,7 @@ tidy_long <- function(x, combine = FALSE, allmeta = FALSE, origmeta = FALSE, pre
prettymeta)
return(if (combine) rbindlist(res, use.names = TRUE, fill = TRUE) else res)
}
metadata <- if (prettymeta) get_metadata(x) else NULL
metadata <- if (prettymeta) get_metadata(x, ...) else NULL
d <- unlist2d(x, "series_key", row.names = "time_period", DT = TRUE) |>
fmutate(time_period = as.Date(time_period),
series_key = qF(series_key)) |>
Expand Down

0 comments on commit d0d26a2

Please sign in to comment.