selectRunAccumulator {openMpp}R Documentation

Select output table accumulator values from model run result

Description

Select output table accumulator values from model run result

Usage

selectRunAccumulator(dbCon, defRs, runId, tableName, accName = NA)

Arguments

dbCon

database connection

defRs

model definition: database rows describing model input parameters and output tables

runId

id of model run results, must be positive integer

tableName

output table name, i.e.: "sexAge"

accName

(optional) output table accumulator name, i.e.: "acc0" if missing or NA then return all accumulators

Details

That call return values of output table accumulators from model run results with id runId.

You can get either value of single accumulator by specifying it name, i.e.: "acc2" or all accumulators if accName argument is missing.

You must use getModel function in order to find model definition defRs.

Value

Data frame of database rows with output table accumulator(s) dimensions and values:

acc_id

accumulator number

sub_id

sub-value number

dim0,...,dimN

dimension items enum ids (not returned if rank is zero)

acc_value

accumulator value

Note

To run examples you must have modelOne database modelOne.sqlite in current directory

Author(s)

amc1999

References

OpenM++ documentation: https://github.com/openmpp/openmpp.github.io/wiki

See Also

getModel getFirstRunId getLastRunId selectRunOutputValue selectRunParameter

Examples

  #
  # connect to database
  #
  theDb <- dbConnect(RSQLite::SQLite(), "modelOne.sqlite", synchronous = "full")
  invisible(dbGetQuery(theDb, "PRAGMA busy_timeout = 86400")) # recommended
  
  # get definition for "modelOne" model
  #
  # use model name only to identify the model
  # if there are multiple versions of the model in database 
  # then first one is selected: where model id = min(model_id) for "modelOne"
  #
  defRs <- getModel(theDb, "modelOne")
  
  # get first run id of that model
  runId <- getFirstRunId(theDb, defRs)
  if (runId <= 0L) stop("model run results not found")
  
  # select accumulator(s) value of "salarySex" from model run results
  #  
  allAccValueRs <- selectRunAccumulator(theDb, defRs, runId, "salarySex")
  acc0_ValueRs <- selectRunAccumulator(theDb, defRs, runId, "salarySex", "acc0")
  
  dbDisconnect(theDb)

[Package openMpp version 0.8.6 Index]