Skip to content

Commit 29ece1b

Browse files
committed
maintain compatability w/ 2012 models
1 parent 4f5ec91 commit 29ece1b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

R/LoadMargins.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ getMarginsTable <- function (model) {
1717
# Change in inventory has negative margins for positive change, which does not accurately portray actual margins either.
1818
purchaser_removal <- sapply(list("Export", "Import", "ChangeInventories"), getVectorOfCodes,
1919
ioschema = model$specs$BaseIOSchema, iolevel = "Detail")
20-
MarginsTable <- MarginsTable[!MarginsTable$IndustryCode%in%purchaser_removal,]
20+
# column names from Margins Tables from 2012 schema were not fixed
21+
col <- ifelse("NIPACode" %in% names(MarginsTable), "NIPACode", "IndustryCode")
22+
MarginsTable <- MarginsTable[!MarginsTable[[col]] %in% purchaser_removal,]
2123
# Remove Scrap, Used and secondhand goods, and Non-comparable imports, and Rest of world adjustment commodities
2224
commodity_removal <- sapply(list("Scrap", "UsedGoods", "NonComparableImport", "RoWAdjustment"), getVectorOfCodes,
2325
ioschema = model$specs$BaseIOSchema, iolevel = model$specs$BaseIOLevel)

0 commit comments

Comments
 (0)