View source: R/tool_expand_tibble.R
tool_expand_tibble | R Documentation |
The data.frame 'd' is expanded in such a manner that all rows with 'NA' in either the 'scenario' or 'region' columns are extended to repeat for all scenarios and regions listed in 'scenarios' and 'regions'. Rows with specified scenarios and/or regions will overwrite extended ones. Regions are expanded before scenarios.
tool_expand_tibble(d, scenarios, regions, structure.columns = NULL)
d |
A data.frame with columns 'scenario' and 'region'. |
scenarios |
A character vector of scenario names. |
regions |
A character vector of region names. |
structure.columns |
A character vector of column names to be carried along. |
A 'tibble'.
## Not run:
tribble(
~scenario, ~region, ~value,
NA, NA, 0,
NA, 'CHA', 1,
'SSP1', NA, 2,
'SSP2EU', 'DEU', 3) %>%
tool_expand_tibble(scenarios = c('SSP1', 'SSP2EU', 'SSP5'),
regions = c('CHA', 'DEU', 'USA')) %>%
pivot_wider(names_from = 'region')
tribble(
~scenario, ~region, ~name, ~value,
NA, NA, 'A', 0,
NA, 'CHA', 'B', 1,
'SSP1', NA, 'A', 2,
'SSP2EU', 'DEU', 'B', 3) %>%
tool_expand_tibble(scenarios = c('SSP1', 'SSP2EU', 'SSP5'),
regions = c('CHA', 'DEU', 'USA'),
structure.columns = 'name')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.