View source: R/plainMethod_buildFromWorkbook.r
buildFromWorkbook | R Documentation |
The function builds a rodeo
-based model by importing
all declarations and equations from a workbook established with common
spreadsheet software.
buildFromWorkbook(workbook, dim = 1, fortran = FALSE, sources = NULL, ...)
workbook |
File path of the workbook. The file type is guessed from the extension which must be '.xlsx' or '.ods'. See below for the mandatory worksheets that must be present in the workbook. |
dim |
The number of spatial compartments, possibly in multiple
dimensions. For single-box models without spatial resolution, use
|
fortran |
Controls the language of code generation. The default
( |
sources |
Only relevant if |
... |
Optional arguments passed to |
An object of class rodeo
.
The file provided as workbook
must contain at least the four
mandatory sheets:
'vars' Declares the state variables of the model. Mandatory columns are 'name', 'unit', 'description'.
'pars' Declares the parameters of the model. Mandatory columns are the same as for sheet 'vars'.
'funs' Declares user-defined functions appearing in any equations of
the model. Mandatory columns are the same as for sheet 'vars'. If
source code is generated for R (fortran=FALSE
), the declared
functions must be accessible in the environment where the model is
run. If fortran=TRUE
, the functions must be implemented in the
file(s) listed in sources
to be included in compilation.
'eqns' Specifies the model equations. Mandatory columns are 'name', 'unit', 'description', 'expression' plus one column for every state variable of the model. The 'expression' columns holds the process rate expressions and columns named after state variables contain the corresponding stoichiometric factors.
The best way to understand the contents of a suitable workbook is to study
the examples in the folder 'models' shipped with the package. Type
system.file("models", package="rodeo")
at the R prompt to see
where this folder is installed on your system.
David Kneis david.kneis@tu-dresden.de
# Build a SEIR type epidemic model
m <- buildFromWorkbook(
system.file("models/SEIR.xlsx", package="rodeo")
)
m$setPars(setNames(m$getParsTable()$default,
m$getParsTable()$name))
m$setVars(setNames(m$getVarsTable()$default,
m$getVarsTable()$name))
x <- m$dynamics(times=0:30, fortran=FALSE)
print(head(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.