Skip to content

Set items of a given (sub-)dimension of a MAgPIE-object

Usage

setItems(x, dim, value, maindim = NULL, raw = FALSE)

Arguments

x

MAgPIE object

dim

Dimension for which the items should be returned. Either number or name of dimension or a vector of these. See dimCode for more details.

value

a vector with the length of the main dimension the dimnames should be replaced in / added to. If set to NULL the corresponding dimension will be removed.

maindim

main dimension the data should be added to (does not need to be set if dim exists in the data. Should be set if dim might not exist, or if dim might potentially exist in a different main dimension than the one anticipated).

raw

if set to FALSE inputs will be corrected (e.g. dots replaced by the letter "p") if necessary. If TRUE data will be written as is (risking the creation of inconsistent objects).

Value

the manipulated MAgPIE object

Author

Jan Philipp Dietrich

Examples

x <- maxample("pop")
setItems(x, "i", paste0("REG", 1:ncells(x)))
#> , , scenario = A2
#> 
#>        t
#> i           y1995   y2005   y2015   y2025   y2035   y2045   y2055
#>   REG1   552.6664  696.44  889.18 1124.11 1389.33 1659.73 1924.19
#>   REG2  1280.6350 1429.53 1518.46 1592.09 1640.95 1671.94 1691.24
#>   REG3   554.4384  582.36  593.76  605.27  614.58  618.97  619.37
#>   REG4   276.3431  295.38  302.62  308.59  313.30  315.72  317.36
#>   REG5   451.9981  558.29  646.02  733.13  812.69  880.98  939.44
#>   REG6   277.7437  390.18  489.22  596.13  698.33  790.61  871.83
#>   REG7   292.1132  326.09  353.25  382.53  409.44  431.12  448.70
#>   REG8   133.7772  152.00  155.27  157.35  158.81  159.70  160.45
#>   REG9   383.2277  534.73  604.94  668.49  723.13  767.30  798.68
#>   REG10 1269.9243 1505.02 1796.76 2095.48 2369.60 2600.68 2783.75
#>        t
#> i         y2065   y2075   y2085   y2095   y2105   y2115   y2125
#>   REG1  2172.30 2387.96 2560.32 2671.07 2708.86 2708.86 2708.86
#>   REG2  1719.25 1765.77 1832.31 1918.47 1965.05 1965.05 1965.05
#>   REG3   618.74  622.03  630.52  642.20  648.98  648.98  648.98
#>   REG4   319.61  322.30  327.08  332.39  334.66  334.66  334.66
#>   REG5   989.54 1035.25 1079.39 1117.61 1134.64 1134.64 1134.64
#>   REG6   942.81 1002.56 1052.19 1088.94 1103.31 1103.31 1103.31
#>   REG7   465.22  481.39  494.88  505.93  511.41  511.41  511.41
#>   REG8   160.95  161.47  163.53  166.31  167.49  167.49  167.49
#>   REG9   819.21  834.31  844.38  843.52  839.53  839.53  839.53
#>   REG10 2920.70 3006.60 3040.10 3007.86 2972.39 2972.39 2972.39
#>        t
#> i         y2135   y2145
#>   REG1  2708.86 2708.86
#>   REG2  1965.05 1965.05
#>   REG3   648.98  648.98
#>   REG4   334.66  334.66
#>   REG5  1134.64 1134.64
#>   REG6  1103.31 1103.31
#>   REG7   511.41  511.41
#>   REG8   167.49  167.49
#>   REG9   839.53  839.53
#>   REG10 2972.39 2972.39
#> 
#> , , scenario = B1
#> 
#>        t
#> i           y1995   y2005   y2015   y2025   y2035   y2045   y2055
#>   REG1   552.6664  721.85  932.04 1118.33 1267.33 1383.24 1469.16
#>   REG2  1280.6350 1429.26 1499.74 1531.12 1518.73 1463.68 1370.97
#>   REG3   554.4384  587.21  603.63  613.98  619.48  617.12  606.77
#>   REG4   276.3431  296.84  305.26  309.78  311.47  309.03  301.99
#>   REG5   451.9981  552.79  623.20  681.60  723.44  747.70  753.98
#>   REG6   277.7437  398.92  502.51  598.73  682.80  754.14  811.59
#>   REG7   292.1132  325.04  349.85  376.11  399.68  418.70  434.27
#>   REG8   133.7772  153.07  157.37  159.07  159.51  158.10  155.21
#>   REG9   383.2277  530.67  590.42  639.68  674.98  692.45  689.79
#>   REG10 1269.9243 1475.64 1687.80 1870.96 1999.15 2072.68 2090.96
#>        t
#> i         y2065   y2075   y2085   y2095   y2105   y2115   y2125
#>   REG1  1510.27 1505.16 1454.54 1361.24 1304.59 1304.59 1304.59
#>   REG2  1257.23 1139.25 1021.52  904.61  846.50  846.50  846.50
#>   REG3   592.52  579.18  567.73  554.61  547.06  547.06  547.06
#>   REG4   292.46  281.39  269.77  257.52  251.04  251.04  251.04
#>   REG5   743.05  718.79  683.68  637.69  611.88  611.88  611.88
#>   REG6   849.11  865.89  861.01  831.23  809.60  809.60  809.60
#>   REG7   449.98  468.05  486.99  503.86  511.44  511.44  511.44
#>   REG8   151.86  148.08  144.47  140.82  138.80  138.80  138.80
#>   REG9   668.98  634.64  590.05  536.24  507.06  507.06  507.06
#>   REG10 2049.18 1953.77 1811.83 1629.07 1528.15 1528.15 1528.15
#>        t
#> i         y2135   y2145
#>   REG1  1304.59 1304.59
#>   REG2   846.50  846.50
#>   REG3   547.06  547.06
#>   REG4   251.04  251.04
#>   REG5   611.88  611.88
#>   REG6   809.60  809.60
#>   REG7   511.44  511.44
#>   REG8   138.80  138.80
#>   REG9   507.06  507.06
#>   REG10 1528.15 1528.15
#>