[Stable]

The fields of an object can be viewed by printing the object. Each field has a corresponding function of the same name to access and modify it's value.

run_dir(m, text)

cmd(m, text)

type(m, text)

parent_run_id(m, text)

parent_run_in(m, text)

parent_ctl_name(m, text)

parent_results_dir(m, text)

unique_id(m, text)

ctl_name(m, text)

results_dir(m, text)

run_in(m, text)

run_id(m, text)

result_files(m, text)

lst_path(m, text)

Arguments

m

An nm object.

text

Optional character for replacing field. If present function will modify field (of same name as function) otherwise will return value of field (of same name as function).

Value

The value of the specified field of m if text is missing. Otherwise an nm object with modified field.

Details

Easiest way to see all fields of an object is to type the object into the console and hit enter. This will display the value of each field.

The fundamental structure of all these functions is the same:

To access the value of a field: m %>% fieldname() or equivalently fieldname(m).

To modify the value of a field: m <- m %>% fieldname("newvalue")

Some fields like cmd are glue fields. In these cases inserting expressions inside braces in text will evaluate the expression (see examples).

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"))


run_dir(m1)
#> [1] "m1"

m1 <- m1 %>% run_dir("{run_id}_dir")
run_dir(m1)
#> [1] "m1_dir"


## set cmd field of m1
m1 <- m1 %>% cmd("execute {ctl_name} -dir={run_dir}")

m1 %>% cmd()
#> [1] "execute runm1.mod -dir=m1_dir"
## displays "execute runm1.mod -dir=m1"

## can also view field when viewing object
m1
#> List of 1
#>  $ execute.Models/m1_dir
#>   ..$ type        : chr "execute"
#>   ..$ run_id      : chr "m1"
#>   ..$ run_in      : chr "Models"
#>   ..$ executed    : logi FALSE
#>   ..$ ctl_contents: chr collapsed - view with ctl_contents()
#>   ..$ ctl_orig    : chr collapsed - view with ctl_orig()
#>   ..$ data_path   : chr "/Users/runner/work/_temp/Library/NMproject/extdata/examples/theopp/SourceData/THEOPP.csv"
#>   ..$ cmd         : chr "execute runm1.mod -dir=m1_dir"
#>   ..$ cores       : int 1
#>   ..$ parafile    : chr "path/to/parafile.pnm"
#>   ..$ run_dir     : chr "m1_dir"
#>   ..$ ctl_name    : chr "runm1.mod"
#>   ..$ results_dir : chr "Results"
#>   ..$ unique_id   : chr "execute.Models/m1_dir"
#>   ..$ lst_path    : chr "m1_dir/NM_run1/psn.lst"
#>   ..- attr(*, "class")= chr [1:3] "nm_execute" "nm_generic" "list"
#>  - attr(*, "class")= chr [1:2] "nm_list" "list"