check_quitte: Check IAMC-style data frame for inconsistencies.

View source: R/check_quitte.R

check_quitteR Documentation

Check IAMC-style data frame for inconsistencies.

Description

Check an IAMC-style data frame to see if values across variables and regions sum up to the totals specified within the data frame.

Usage

check_quitte(quitte, check_variables, check_regions = NULL)

Arguments

quitte

IAMC-style data frame.

check_variables

List, string or file of variables to check.

check_regions

List, string or file of regions to check.

Details

Checking is performed for all variables and regions in check_variables and check_regions, which can be passed as a list of format

list("sum" = c("summand1", "summand2", ...))

a character string of format

sum1
summand1a
summand1b

sum2
summand2a
...

or as the path to a text file with this format.

If checking should be performed for variables or regions that are neither sum nor summand (e.g., the variable 'GDP' should be summed across regions, but is itself not a sum of other variables), include them as sum and their only summand in the respective list (i.e., list("GDP" = "GDP") or as a double line in the character string or file.

If check_regions is NULL, variables are check across all regions in quitte.

Value

A data frame of all entries that did not match.

Author(s)

Michaja Pehl

Examples

require(dplyr, quietly = TRUE, warn.conflicts = FALSE)
quitte <- rbind(
    data.frame(
        model    = "REMIND",
        scenario = "Baseline",
        region   = c("World", "USA", "EUR"),
        variable = "GDP",
        unit     = "US$2005",
        period   = 2005,
        value    = c(3, 1, 1)
    ),

    data.frame(
        model    = "REMIND",
        scenario = "Baseline",
        region   = "ROW",
        variable = c("FE|Total", "FE|Solids", "FE|Electricity"),
        unit     = "EJ/a",
        period   = 2005,
        value    = c(3, 1, 1)
    )
)

check_variables <- list(
    "FE|Total" = c("FE|Solids", "FE|Electricity"),
    "GDP"      = "GDP")

check_regions <- paste0("World\nUSA\nEUR\n\nROW\nROW")

print(quitte)
print(check_variables)
cat(check_regions)

check_quitte(quitte, check_variables, check_regions)


pik-piam/quitte documentation built on April 26, 2024, 12:58 a.m.