Learn R Programming

magclass (version 6.13.2)

collapseDim: Collapse dataset dimensions

Description

This function will remove names in the data dimension which are the same for each element (meaning that this data dimension contains exactly one element) or, if forced, remove any other subdimension. It is a generalized version of the function collapseNames

Usage

collapseDim(x, dim = NULL, keepdim = NULL)

Value

The provided MAgPIE object with collapsed dimensions

Arguments

x

MAgPIE object

dim

Either NULL, dimension code or name of dimension or a vector of these. If set to NULL all single entry subdimensions will be removed as they are irrelevant to uniquely identfy a data element. If specified, only the specified subdimensions will be removed (See dimCode for more details how to specify a subdimension). CAUTION: The function also allows to specify subdimensions which are otherwise needed to clearly identify an entry. By removing these subdimensions duplicates in the data will be created potentially causing problems in the further use of the data set. Be careful in removing subdimensions.

keepdim

(only considered if dim is not specified) Can be used to converse single element subdimension which otherwise would get deleted. If dim is specified this setting will not have any effect.

Author

Jan Philipp Dietrich

See Also

getItems "magpie"

Examples

Run this code

x <- new.magpie(c("GLO.1", "GLO.2"), 2000, c("bla.a", "bla.b"))
collapseDim(x)
collapseDim(x, keepdim = 1:2)
collapseDim(x, dim = 1.1)
collapseDim(x, dim = 3.2)

Run the code above in your browser using DataLab