diff --git a/R/StateEEIOCalculations.R b/R/StateEEIOCalculations.R index 93c144f..4dad8b6 100644 --- a/R/StateEEIOCalculations.R +++ b/R/StateEEIOCalculations.R @@ -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) diff --git a/examples/CalculateStateCBE.Rmd b/examples/CalculateStateCBE.Rmd index a85a322..17b9e70 100644 --- a/examples/CalculateStateCBE.Rmd +++ b/examples/CalculateStateCBE.Rmd @@ -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)) ```