rwtbl_add_rise_vars: Add required RISE variables to rwtbl

Description Usage Arguments Value Examples

View source: R/rwtbl_add_rise_vars.R

Description

rwtbl_add_rise_vars() takes in an rwtbl and adds in the variables required for publication in RISE. It does so by converting variables from the rwtbl to the corresponding required object name in the RISE json format. Some columns some are constructed from one or more variables in the rwtbl, a few must be provided by the user (ui_vars), and others are constructed from attributes in the rwtbl. rwtbl_cols_for_rise includes all of the columns that are required in the rwtbl for this function to work properly.

Usage

1
rwtbl_add_rise_vars(rwtbl, ui_vars)

Arguments

rwtbl

A tbl_df with expected columns. Likely this is output from RWDataPlyr::rdf_to_rwtbl2()

ui_vars

User specified values (as a list) for the sourceCode, modelNameSourceCode, status, and modelRunDescription fields in the RISE json file.

Value

tbl with all required objects for RISE json file as column names

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
ifile <- system.file(
  'extdata/Scenario/ISM1988_2014,2007Dems,IG,Most',
  "KeySlots.rdf",
 package = "RWDataPlyr"
)

# get the tbl using RWDataPlyr
rwtbl <- RWDataPlyr::rdf_to_rwtbl2(
  ifile,
  scenario = "test",
  keep_cols = rwtbl_cols_for_rise
)

# manually specify some parameters:
ui_vars <- list(
  sourceCode = "CRSS-TestData",
  modelNameSourceCode = "CRSS",
  status = "Finalized Dec. 2012. To RISE v0.0.1",
  modelRunDescription = "desc"
)

# get the rest of the parameters automatically
rise_tbl <- rwtbl_add_rise_vars(rwtbl, ui_vars)

BoulderCodeHub/rdf2rise documentation built on Nov. 22, 2019, 5:29 p.m.