An experiment in turning an Excel file into an R program. It takes as inputs an excel file (in xlsx format) a set of cell references as inputs and a set of cell references as outputs and returns a function that can be used to “execute” the excel workbook from R. Currently only very basic excel operations are supported.

For example, this excel workbook implements a tree model with inputs on the first sheet and outputs on the second.

path <- system.file("example/tree.xlsx", package = "xlerate")

The inputs are on the first tab, making up a column with a few gaps, and with labels in the column to its left:

inputs <- xlerate::xlerate_ref(
c("D3:D13", "D15:D16", "D18:D21"),
1, list(col = -1))

The outputs are all over the second sheet and have labels two rows below

outputs <- xlerate::xlerate_ref(
c("C40", "E34", "E50", "G29", "G38", "G45", "G54"),
2, list(row = 2))

Then create a function that can generate these outputs

tree <- xlerate::xlerate(path, inputs, outputs)
tree
## <an xlerate object>
tree(c("pTST_pos" = 0.01))
##        TST        pos        neg       LTBI  LTBI free       LTBI
##   71.90691  500.00000   67.58273 1342.00000    0.00000 1342.00000
##  LTBI free
##    0.00000