R/convertAmmoniaProductionUSGS.R

Defines functions convertAmmoniaProductionUSGS

convertAmmoniaProductionUSGS <- function(x){
  
  usgstomagpie <-  read.csv("CountryUSGStoMAgPIE.csv", stringsAsFactors = FALSE)
 tmp <- getRegions(x)
    tmp[match(usgstomagpie$Country.USGS, tmp, nomatch = FALSE)] <- usgstomagpie$Country.MagPIE
    getRegions(x) <- tmp
  map <- toolMappingFile(type="regional", readcsv=T, name="regionmappingMAgPIE.csv")
  
  y <- toolAggregate(x,map, partrel=T, from=1, to=2)
  y <- toolCountryFill(y,fill = 0)
  y[is.na(y)] <- 0

  return(y)
}
pik-piam/moinput documentation built on June 9, 2020, 12:23 p.m.