Skip to content

Commit

Permalink
update WEO, April 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuoxv committed Apr 17, 2024
1 parent c345455 commit 3d5329c
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 48 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Imports:
dplyr,
forcats,
Expand Down
17 changes: 8 additions & 9 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Menu, current
#'
#' @source https://www.imf.org/en/Publications/WEO/weo-database/2023/October
#' @source https://www.imf.org/en/Publications/WEO/weo-database/2024/April
#' @format A list.
#' \describe{
#' \item{a_menu}{
Expand All @@ -26,8 +26,7 @@

#' Meta data, current
#'
#' @source https://www.imf.org/en/Publications/WEO/weo-database/2023/April/download-entire-database
#' @format A list.
#' @source https://www.imf.org/en/Publications/WEO/weo-database/2024/April
#' \describe{
#' \item{area}{
#' @format A tibble.
Expand All @@ -44,9 +43,9 @@

#' IMF World Economic Outlook data, current
#'
#' Economic data published in October 2023.
#' Economic data published in April 2024.
#'
#' @source https://www.imf.org/en/Publications/WEO/weo-database/2023/October
#' @source https://www.imf.org/en/Publications/WEO/weo-database/2024/April
#' @format A tibble.
#' \describe{
#' \item{unit}{refer to meta unit}
Expand All @@ -59,13 +58,13 @@
#' \item{year}{year like 1980}
#' \item{value}{observed value}
#' }
"data_2310"
"data_2404"

#' IMF World Economic Outlook data, previous
#'
#' Economic data published in April 2023. Cut to since 2019 only.
#' Economic data published in October 2023. Cut to since 2020 only.
#'
#' @source https://www.imf.org/en/Publications/WEO/weo-database/2023/April
#' @source https://www.imf.org/en/Publications/WEO/weo-database/2023/October
#' @format A tibble.
#' \describe{
#' \item{unit}{refer to meta unit}
Expand All @@ -78,4 +77,4 @@
#' \item{year}{year like 1980}
#' \item{value}{observed value}
#' }
"data_2304_cut"
"data_2310_cut"
2 changes: 1 addition & 1 deletion R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' }
mainApp <- function(data_current, data_prev, name_current, name_prev) {
# Define UI for application
ui <- navbarPage("IMF World Economic Outlook, October 2023",
ui <- navbarPage("IMF World Economic Outlook, April 2024",

tags$head(includeHTML(("google-analytics.html"))),
selected = "By area",
Expand Down
10 changes: 5 additions & 5 deletions R/selectArea.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ selectAreaUI <- function(id, a_menu, c_menu) {
sliderInput(NS(id, "year_range"),
label = h4("Select year range"),
min = 1980,
max = 2028,
value = c(1980, 2028),
max = 2029,
value = c(1980, 2029),
sep = ""
),

# Toggle add previous forecast or not
radioButtons(NS(id, "previous"), "Add April 2023 forecast?", c("Yes", "No"),
radioButtons(NS(id, "previous"), "Add October 2023 forecast?", c("Yes", "No"),
selected = "No"),

# Show source and Shiny app creator
a(
href = "https://www.imf.org/en/Publications/WEO/weo-database/2023/October",
href = "https://www.imf.org/en/Publications/WEO/weo-database/2024/April",
"Source: IMF"
),
br(),
Expand Down
4 changes: 2 additions & 2 deletions app.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pkgload::load_all(".")
mainApp(data_current = data_2310, data_prev = data_2304_cut,
name_current = "2310", name_prev = "2304")
mainApp(data_current = data_2404, data_prev = data_2310_cut,
name_current = "2404", name_prev = "2310")
4 changes: 2 additions & 2 deletions appFileManifest
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ R/main.R
R/output.R
R/selectArea.R
R/utils-pipe.R
data/data_2304_cut.rda
data/data_2310.rda
data/data_2310_cut.rda
data/data_2404.rda
data/menu.rda
data/meta.rda
google-analytics.html
8 changes: 4 additions & 4 deletions data-raw/cut_previous.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
library(tidyverse)

load("data-old/data_2304.rda")
load("data-old/data_2310.rda")

data_2304_cut <- data_2304 %>%
filter(year >= 2019)
data_2310_cut <- data_2310 %>%
filter(year >= 2020)

usethis::use_data(data_2304_cut)
usethis::use_data(data_2310_cut)
14 changes: 7 additions & 7 deletions data-raw/setup_current.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ library(tidyverse)
library(janitor)

# Bulk download from IMF World Economic Outlook Database
# https://www.imf.org/en/Publications/WEO/weo-database/2023/October/download-entire-database
sdmx_file <- "downloads/WEO_PUB_OCT2023.xml"
# https://www.imf.org/en/Publications/WEO/weo-database/2024/April/download-entire-database
sdmx_file <- "downloads/WEO_PUB_APR2024.xml"

sdmx <- rsdmx::readSDMX(sdmx_file, isURL = FALSE)

Expand Down Expand Up @@ -32,8 +32,8 @@ weo_df <- weo_df %>%
)

# Download meta data
# https://www.imf.org/en/Publications/WEO/weo-database/2023/October/download-entire-database
meta_file <- "downloads/weooct2023-sdmx-dsd.xlsx"
# https://www.imf.org/en/Publications/WEO/weo-database/2024/April/download-entire-database
meta_file <- "downloads/weopub-dsd-apr2024.xlsx"

sheets <- readxl::excel_sheets(meta_file)

Expand Down Expand Up @@ -123,8 +123,8 @@ names(scales) <- meta_list[[6]]$description
names(scales)[3:4] <- ""

# make a list
data_2310 <- weo_df %>%
replace_na(list(scale = 1)) # avoid NAs in scale in 2310
data_2404 <- weo_df %>%
replace_na(list(scale = 1)) # avoid NAs in scale in 2404

menu <- list(
a_menu = list(
Expand All @@ -147,6 +147,6 @@ meta <- list(
)

# save
usethis::use_data(data_2310, menu, meta, overwrite = TRUE)
usethis::use_data(data_2404, menu, meta, overwrite = TRUE)


Binary file removed data/data_2304_cut.rda
Binary file not shown.
Binary file removed data/data_2310.rda
Binary file not shown.
Binary file added data/data_2310_cut.rda
Binary file not shown.
Binary file added data/data_2404.rda
Binary file not shown.
Binary file modified data/menu.rda
Binary file not shown.
Binary file modified data/meta.rda
Binary file not shown.
10 changes: 5 additions & 5 deletions man/data_2310.Rd → man/data_2310_cut.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/data_2304_cut.Rd → man/data_2404.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/menu.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions man/meta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3d5329c

Please sign in to comment.