RenameAndAggregate: RenameAndAggregate

View source: R/RenameAndAggregate.R

RenameAndAggregateR Documentation

RenameAndAggregate

Description

Rename and aggregate data using a mapping

Reads in a substitutes names of variables according to the mapping, multiplies reported values by an optional factor in a column named "factor" of the mapping, and saves the output in a new *.mif

Usage

RenameAndAggregate(data, mapping, missing_log = NULL)

Arguments

data

Lists with list of magpie-objects (a magpie-object as created by read.report), first list containts scenarios, second list the models

mapping

mapping of the variable names of the read-in mif. The header is used for naming. The format of the mapping should be: 1st column the standard naming in PIK mif format. X further columns that contain the indicator names in the reporting format. Can also contain several indicator columns (e.g Variable and Item). Optional columns with reserved names are unit, weight, factor, and spatial. Factor is a number that the results will be multiplied with (e.g. to transform CO2 into C). Weight is needed if several mif indicators shall be aggregated to one reporting indicator. You always need a weight column if you have multiple mif to one reporting mappings. If you have a weight column, you have to have values in it for all indicators. If NULL, the results are added up; if you provide an indicator name (of a mif indicator), this indicator will be used for the weighting of a weighted mean. Spatial should be set to "glo" for mif indicators that shall only be reported globally and "reg" for only reporting locally. The default is "reg+glo", which implies reporting on global and local level. In the case of aggregation, contradicting entries in spatial column for the same reporting indicator will throw an error. Unit is a name of the unit without () Example: "magpie";"agmip";"item";"unit";"weight";"factor" "Nutrition|+|Calorie Supply (kcal/capita/day)";"CALO";"AGR";"kcal/capita/day";"NULL";1

missing_log

name of logfile to record variables which are present in the mapping but missing in the mif file. By default, no logfile is produced

Author(s)

Christoph Bertram, Lavinia Baumstark, Anastasis Giannousakis, Florian Humpenoeder, Falk Benke, Benjamin Leon Bodirsky

See Also

write.report

Examples


## Not run: 
RenameAndAggregate(list(model=list(scenario=population_magpie)),"Mapping_generic_ADVANCE.csv")

## End(Not run)


IAMconsortium/iamc documentation built on July 8, 2023, 11:35 p.m.