library(dplyr) library(tidyr) # if not yet done install the iotr package # library(devtools) # install_github(repo = "okrebs/iotr") library(iotr)
We begin by downloading and tidying input output tables from the World Input Output Database (see Timmer, M. P., Dietzenbacher, E., Los, B., Stehrer, R. and de Vries, G. J. (2015), "An Illustrated User Guide to the World Input–Output Database: the Case of Global Automotive Production", Review of International Economics., 23: 575–605, www.wiod.org).
wiot <- get_wiot(years = c(2000, 2014)) %>% wiot2long() %>% filter(Country != "TOT") %>% select(origin = Country, sector = RNr, destination, use, flow, year = Year)
We adopt the initial, raw WIOD data the following three ways:
wiot <- wiot %>% # apply the respective function to the IO table from each year separately nest_by(year, .key = "iot") %>% mutate(iot = list(rm_negative_vad(iot, category_to_scale = 57) %>% rm_dynamics(dynamic_categories = c(60, 61), category_to_scale = 57))) # after adapting dynamic use categories combine all final use types into one wiot <- wiot %>% unnest(cols = c(iot)) %>% mutate(use = ifelse(use > 57, 57L, as.integer(use))) %>% group_by(year, origin, sector, destination, use) %>% summarise(flow = sum(flow), .groups = "drop") %>% nest(iot = c(origin, sector, destination, use, flow)) wiot <- wiot %>% rowwise() %>% # wiot is in millions so 1e-6 is $1 mutate(iot_nozero = list(gen_own_trade(iot, max_replace = 1e-6))) %>% pivot_longer(c(iot, iot_nozero), names_to = "includes_zeros", names_transform = list("includes_zeros" = ~.x == "iot"), values_to = "iot") # we only use the WIOD from 2000 as a robustness check and so do not need the # version that includes zeros wiot <- wiot %>% filter(year != 2000 | includes_zeros == FALSE)
This gives us three IO tables, one for the year 2000 with problematic zero own trade flows removed and two tables for 2014, with and without these zeros. Due to its size this data set is not made available via github. Run the code wiot.R in the data-raw folder of the source package to create it.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.