Lifecycle: experimental R-CMD-check
{readweo} is an R package that helps you download, import and tidy
data from the IMF’s World Economic Outlook.
You can install {readweo} from GitHub with:
# install.packages("devtools") devtools::install_github("MattCowgill/readweo")
{readweo} is not currently on CRAN. At present I do not plan to submit
it to CRAN.
The package has one key function: read_weo().
You can use it like so:
×ばつ 13 #> weo_count...1 iso weo_s...2 country subje...3 subje...4 units scale count...5 estim...6 #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <dbl> #> 1 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 2 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 3 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 4 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 5 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 6 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 7 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 8 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 9 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 10 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> # ... with 308,004 more rows, 3 more variables: year <dbl>, value <dbl>, #> # weo_date <date>, and abbreviated variable names 1weo_country_code, #> # 2weo_subject_code, 3subject_descriptor, 4subject_notes, #> # 5country_series_specific_notes, 6estimates_start_after">
library(readweo) weo <- read_weo("Oct 2022") weo #> # A tibble: 308,014 ×ばつ 13 #> weo_count...1 iso weo_s...2 country subje...3 subje...4 units scale count...5 estim...6 #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <dbl> #> 1 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 2 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 3 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 4 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 5 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 6 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 7 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 8 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 9 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> 10 512 AFG NGDP_R Afghan... Gross ... Expres... Nati... Bill... Source... 2020 #> # ... with 308,004 more rows, 3 more variables: year <dbl>, value <dbl>, #> # weo_date <date>, and abbreviated variable names 1weo_country_code, #> # 2weo_subject_code, 3subject_descriptor, 4subject_notes, #> # 5country_series_specific_notes, 6estimates_start_after
read_weo() returns a tidy (long) tibble.
You can use it like this:
library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union library(ggplot2) weo %>% filter(country %in% c("New Zealand", "Australia"), subject_descriptor == "Unemployment rate") %>% ggplot(aes(x = year, y = value, col = country)) + geom_line() + geom_vline(aes(xintercept = estimates_start_after), linetype = 2) + theme_minimal() + labs(subtitle = "Unemployment rate with IMF forecast")