[Stable]

Uses dataset to automatically fill $INPUT in control file.

fill_input(m, ...)

Arguments

m

An nm object.

...

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

Value

An nm object with modified ctl_contents field.

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.

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
#> $`execute.Models/m1`
#>   1| $INPUT ...
#> 

m1 <- m1 %>% fill_input()
m1 %>% dollar("INPUT") ## view $INPUT
#> $`execute.Models/m1`
#>   1| $INPUT
#>   2| ID AMT TIME DV WT
#> 

## following will will drop the "RATE" column
m1 <- m1 %>% fill_input(drop = "RATE")
## no RATE column so will not drop anything
m1 %>% dollar("INPUT") 
#> $`execute.Models/m1`
#>   1| $INPUT
#>   2| ID AMT TIME DV WT
#> 

## 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
#> $`execute.Models/m1`
#>   1| $INPUT
#>   2| ID AMT TIME DV WT
#>