R/reportIncome.R

Defines functions reportIncome

Documented in reportIncome

#' @title reportIncome
#' @description reports income
#'
#' @export
#'
#' @param gdx  GDX file
#' @param type ppp for purchase power parity, mer for market exchange rate
#' @param level spatial aggregation: "reg", "glo", "regglo", "iso"
#' @return Annual per capita and total income as MAgPIE object (US$2005 MER/cap/yr and million US$05 PPP/yr)
#' @author Florian Humpenoeder, Isabelle Weindl, Felicitas Beier
#' @examples
#' \dontrun{
#' x <- reportIncome(gdx)
#' }
#'
reportIncome <- function(gdx, type = "ppp", level = "regglo") {

  # read in regional data
  perCapita  <- income(gdx, type = type, level = level)
  total      <- income(gdx, type = type, level = level, per_capita = FALSE)

  # rename
  if (type == "ppp") {

    getNames(perCapita)  <- "Income (US$05 PPP/cap/yr)"
    getNames(total)      <- "Total income (million US$05 PPP/yr)"

  } else if (type == "mer") {

    getNames(perCapita)  <- "Income (US$05 MER/cap/yr)"
    getNames(total)      <- "Total income (million US$05 MER/yr)"

  } else {
    stop("Please specify reporting type for income units: mer or ppp")
  }

  out <- mbind(perCapita, total)

  return(out)
}
pik-piam/magpie4 documentation built on April 22, 2024, 3:34 p.m.