Skip to content

Commit

Permalink
reverse signs on trade balance, only show summary totals see USEPA/St…
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Oct 28, 2024
1 parent 4f74050 commit 761bec4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/StateEEIOCalculations.R
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ calculateCBETradeBalance <- function(model) {
use_domestic_requirements=TRUE, show_RoW=TRUE)[["LCIA_d"]])
E_m_RoW <- E_m_RoW[grepl('/RoW', row.names(E_m_RoW)), , drop=FALSE]

CBE_trade <- data.frame(cbind(E_x_RoUS, E_x_RoW, -E_m_RoUS, -E_m_RoW))
CBE_trade <- data.frame(cbind(-E_x_RoUS, -E_x_RoW, E_m_RoUS, E_m_RoW))
colnames(CBE_trade) <- c("export_RoUS","export_RoW","import_RoUS","import_RoW")
rownames(CBE_trade) <- gsub("/.*","",rownames(CBE_trade))
CBE_trade$Balance <- rowSums(CBE_trade)
Expand Down
7 changes: 6 additions & 1 deletion examples/CalculateStateCBE.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,12 @@ cbe_trade_all <- sapply(models, calculateCBETradeBalance, simplify=FALSE, USE.NA
cbe_trade_all_df <- sapply(cbe_trade_all, matricizeandflip)
rownames(cbe_trade_all_df) <- c("Exports to RoUS", "Exports to RoW", "Imports from RoUS",
"Imports from RoW", "Balance")
trade_balance <- lineChartFigure(cbe_trade_all_df / 10^9, "Greenhouse Gases (million tonnes)")
cbe_trade_summary_df <- rbind(colSums(cbe_trade_all_df[c(1, 2),]),
colSums(cbe_trade_all_df[c(3, 4),]),
cbe_trade_all_df[c(5),])
rownames(cbe_trade_summary_df) <- c("Exports", "Imports", "Balance")
# Alternatively can chart "cbe_trade_all_df" to differentiate RoW and RoUS
trade_balance <- lineChartFigure(cbe_trade_summary_df / 10^9, "Greenhouse Gases (million tonnes)")
trade_balance <- trade_balance + theme(text = element_text(size=12))
```

Expand Down

0 comments on commit 761bec4

Please sign in to comment.