fill_input: Fill $INPUT

View source: R/basic-ctl-manipulation.R

fill_inputR Documentation

Fill $INPUT

Description

[Stable]

Uses dataset to automatically fill $INPUT in control file.

Usage

fill_input(m, ...)

Arguments

m

An nm object.

...

Either keep, drop, or rename arguments. See examples.

Details

If a new dataset with different columns is assigned to an nm object, $INPUT will not be correct and so it may necessary to apply fill_input() again.

See examples for how to use drop and rename arguments to control how $INPUT is written.

Value

An nm object with modified ctl_contents field.

Examples


# create example object m1 from package demo files
exdir <- system.file("extdata", "examples", "theopp", package = "NMproject")
m1 <- new_nm(run_id = "m1", 
             based_on = file.path(exdir, "Models", "ADVAN2.mod"),
             data_path = file.path(exdir, "SourceData", "THEOPP.csv"))

m1 %>% dollar("INPUT") ## shows placeholder for column names

m1 <- m1 %>% fill_input()
m1 %>% dollar("INPUT") ## view $INPUT

## following will will drop the "RATE" column
m1 <- m1 %>% fill_input(drop = "RATE")
## no RATE column so will not drop anything
m1 %>% dollar("INPUT") 

## following will rename "DATE" to be "DAT0"
m1 <- m1 %>% fill_input(rename = c("DAT0" = "DATE"))
## no DATE column so will not rename anything
m1 %>% dollar("INPUT") ## view $INPUT


NMproject documentation built on Sept. 30, 2022, 1:06 a.m.