Description Usage Arguments Value Note Author(s) Examples
Wrapper function to run an arbitrarily complex model using a minimalistic interface.
1 | runModel(model, input, outdir)
|
model |
Function representing the model. It is called as
|
input |
List with model inputs. See below for expected contents. |
outdir |
Name of an existing directory where any output files created
by |
The return value of model
.
The following columns are mandatory in data frame input
:
name
: Denotes an input item of the model. Typically it is a
parameter, a variable, or a dimension constant
(character string).
value
: Value of the input item (numeric).
label
: Short, human-readable label for the input item
(character string). Can be used, e.g., in graphics
produced by the model. Example: For a variable with
name 'NO3', the label could be 'Nitrate (mg/l)'.
David Kneis david.kneis@tu-dresden.de
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # This model does no computations, it only creates a html table of its inputs
input= list(tbl=data.frame(name=c("a","b"), value=1:2))
model= function(input, outdir) {
html= paste0("<table border=1>\n <tr><th> ",paste(names(input$tbl),
collapse=paste0(" </th><th> "))," </th></tr>\n")
for (i in 1:nrow(input$tbl)) {
html= paste0(html," <tr>",paste0("<td style='text-align:right'> ",
unlist(input$tbl[i,])," </td>",collapse=""),"</tr>\n")
}
html= paste0(html,"</table>\n")
write(file=paste(outdir,"out.html",sep="/"), x=html)
return(invisible(NULL))
}
outdir=tempdir()
runModel(model=model, input=input, outdir=outdir)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.