Skip to contents

Get data from IDEEA package embedded dataset

Usage

get_ideea_data(
  name,
  nreg = 5,
  variable = ".",
  sets = .ideea_sets_mask,
  agg_fun = sum,
  raw = FALSE,
  offshore = FALSE,
  islands = TRUE,
  as_DT = TRUE,
  drop_na = TRUE,
  rename = FALSE,
  reg_tbl = ideea_data$reg_tbl,
  weight = ifelse(identical(agg_fun, sum), "km2", 1)
)

Arguments

name

character, name of data table, one of: "coal", "oil", "gas", "biomass", "lignite", ...

nreg

integer, number of region to return

variable

character, regular expression for the name of variable(s) to return.

sets

character, a regular expression to identify key-columns in the datasets, used for grouping. The default value (IDEEA:::.ideea_sets_pattern) covers all sets in the embedded to the package data. If new datasets added with different names of sets, the default value has to be reviewed.

agg_fun

character, function to aggregate data by region, default "sum" (for volumes), "mean" is advised for costs variable.

raw

logical, should the raw table be returned, FALSE by default

offshore

logical, should the data for offshore areas be returned, FALSE by default

islands

logical, should the data for remote islands be returned, FALSE by default

as_DT

logical, results will be returned in data.table format if TRUE (default)

drop_na

logical, should NA values be dropped from the data

reg_tbl

data.frame with regional mapping (for custom weights or regions)

weight

character name of column to use as disaggregating weights if the disaggregation of the data is required, for example the saved data is by 5 regions, but the requested data is for 32 regions. In general, it is not recommended to disaggregate due to the strong assumptions. But the algorithm is also used to convert data from 36 to 32 regions because of not exact match of regions' shapes (see Regions article). The default value is the area of the region ("km^2") for agg_fun = sum and it is equal to 1 (no weights) for agg_fun = mean and all other functions.

Value

returns the requested table or NULL.

Examples

get_ideea_data("coal", raw = T)
#>      reg36                 name36 mainland offshore   reg1  name1
#>     <char>                 <char>   <lgcl>   <lgcl> <char> <char>
#>  1:     AP         Andhra Pradesh     TRUE    FALSE    IND  India
#>  2:     AR      Arunachal Pradesh     TRUE    FALSE    IND  India
#>  3:     AS                  Assam     TRUE    FALSE    IND  India
#>  4:     BR                  Bihar     TRUE    FALSE    IND  India
#>  5:     CH             Chandigarh     TRUE    FALSE    IND  India
#>  6:     CT           Chhattisgarh     TRUE    FALSE    IND  India
#>  7:     DD          Daman and Diu     TRUE    FALSE    IND  India
#>  8:     DL                  Delhi     TRUE    FALSE    IND  India
#>  9:     DN Dadra and Nagar Haveli     TRUE    FALSE    IND  India
#> 10:     GA                    Goa     TRUE    FALSE    IND  India
#> 11:     GJ                Gujarat     TRUE    FALSE    IND  India
#> 12:     HP       Himachal Pradesh     TRUE    FALSE    IND  India
#> 13:     HR                Haryana     TRUE    FALSE    IND  India
#> 14:     JH              Jharkhand     TRUE    FALSE    IND  India
#> 15:     JK      Jammu and Kashmir     TRUE    FALSE    IND  India
#> 16:     KA              Karnataka     TRUE    FALSE    IND  India
#> 17:     KL                 Kerala     TRUE    FALSE    IND  India
#> 18:     MH            Maharashtra     TRUE    FALSE    IND  India
#> 19:     ML              Meghalaya     TRUE    FALSE    IND  India
#> 20:     MN                Manipur     TRUE    FALSE    IND  India
#> 21:     MP         Madhya Pradesh     TRUE    FALSE    IND  India
#> 22:     MZ                Mizoram     TRUE    FALSE    IND  India
#> 23:     NL               Nagaland     TRUE    FALSE    IND  India
#> 24:     OR                 Odisha     TRUE    FALSE    IND  India
#> 25:     PB                 Punjab     TRUE    FALSE    IND  India
#> 26:     PY             Puducherry     TRUE    FALSE    IND  India
#> 27:     RJ              Rajasthan     TRUE    FALSE    IND  India
#> 28:     SK                 Sikkim     TRUE    FALSE    IND  India
#> 29:     TG              Telangana     TRUE    FALSE    IND  India
#> 30:     TN             Tamil Nadu     TRUE    FALSE    IND  India
#> 31:     TR                Tripura     TRUE    FALSE    IND  India
#> 32:     UP          Uttar Pradesh     TRUE    FALSE    IND  India
#> 33:     UT            Uttarakhand     TRUE    FALSE    IND  India
#> 34:     WB            West Bengal     TRUE    FALSE    IND  India
#>      reg36                 name36 mainland offshore   reg1  name1
#>     total_reserve_Mt production_2021 cost_USD_t_2020
#>                <num>           <num>           <num>
#>  1:          4141.87              NA              50
#>  2:            90.23              NA              50
#>  3:           525.01           0.036              50
#>  4:          4437.18              NA              50
#>  5:               NA              NA              NA
#>  6:         74191.76         158.409              50
#>  7:               NA              NA              NA
#>  8:               NA              NA              NA
#>  9:               NA              NA              NA
#> 10:               NA              NA              NA
#> 11:               NA              NA              NA
#> 12:               NA              NA              NA
#> 13:               NA              NA              NA
#> 14:         86660.10         119.296              50
#> 15:               NA              NA              NA
#> 16:               NA              NA              NA
#> 17:               NA              NA              NA
#> 18:         13220.71          47.435              50
#> 19:           576.48              NA              50
#> 20:               NA              NA              NA
#> 21:         30916.73         132.531              50
#> 22:               NA              NA              NA
#> 23:           478.31              NA              50
#> 24:         88104.60         154.150              50
#> 25:               NA              NA              NA
#> 26:               NA              NA              NA
#> 27:               NA              NA              NA
#> 28:           101.23              NA              50
#> 29:         23034.20          52.603              50
#> 30:               NA              NA              NA
#> 31:               NA              NA              NA
#> 32:          1061.80          17.016              50
#> 33:               NA              NA              NA
#> 34:         33871.25          34.596              50
#>     total_reserve_Mt production_2021 cost_USD_t_2020
get_ideea_data("coal", nreg = 7, "reserve")
#>         reg7 mainland offshore total_reserve_Mt
#>       <char>   <lgcl>   <lgcl>            <num>
#> 1:      EAST     TRUE    FALSE        213174.36
#> 2:     NORTH     TRUE    FALSE          1061.80
#> 3: NORTHEAST     TRUE    FALSE          1670.03
#> 4:     SOUTH     TRUE    FALSE         27176.07
#> 5:      WEST     TRUE    FALSE        118329.20
get_ideea_data("oil", nreg = 34, "reserve", islands = T)
#>     reg34 offshore mainland oil_reserve_Mt_2021 oil_reserve_GWh_2021
#>    <char>   <lgcl>   <lgcl>               <num>                <num>
#> 1:    APY    FALSE     TRUE                7.33              85247.9
#> 2:     AR    FALSE     TRUE                3.64              42333.2
#> 3:     AS    FALSE     TRUE              153.05            1779971.5
#> 4:    GJD    FALSE     TRUE                2.38              27679.4
#> 5:     NL    FALSE     TRUE               34.77             404375.1
#> 6:     RJ    FALSE     TRUE                9.08             105600.4
#> 7:    TNY    FALSE     TRUE                0.07                814.1
#> 8:     TR    FALSE     TRUE              219.27            2550110.1
get_ideea_data("coal", nreg = 7, "cost", agg_fun = mean)
#>         reg7 mainland offshore cost_USD_t_2020
#>       <char>   <lgcl>   <lgcl>           <num>
#> 1:      EAST     TRUE    FALSE              50
#> 2:     NORTH     TRUE    FALSE              50
#> 3: NORTHEAST     TRUE    FALSE              50
#> 4:     SOUTH     TRUE    FALSE              50
#> 5:      WEST     TRUE    FALSE              50
get_ideea_data("merra_raw_2014", raw = T) |> head()
#> Key: <UTC, locid>
#>                    UTC  locid  W10M  W50M SWGDN ALBEDO
#>                 <POSc>  <int> <num> <num> <int>  <num>
#> 1: 2014-01-01 00:30:00 109878   5.6   6.0    63   0.12
#> 2: 2014-01-01 00:30:00 109879   4.4   4.7    71   0.12
#> 3: 2014-01-01 00:30:00 110453   6.7   7.3    53   0.13
#> 4: 2014-01-01 00:30:00 110454   5.6   6.0    61   0.13
#> 5: 2014-01-01 00:30:00 110455   4.2   4.5    51   0.12
#> 6: 2014-01-01 00:30:00 111028   8.9   9.9    19   0.10