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.
knitr::opts_chunk$set(error = FALSE)
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
tree(c("pTST_pos" = 0.01))
Another example, this time a Markov model
path <- system.file("example/markov.xlsx", package = "xlerate") inputs <- xlerate::xlerate_ref("B1:B10", 1, list(col = -1)) outputs <- xlerate::xlerate_ref(c("I25", "O24", "U25", "AA24"), 1, list(col = -1)) markov <- xlerate::xlerate(path, inputs, outputs) markov(c("Prob state 1 >2" = 0.1))
MIT © Imperial College of Science, Technology and Medicine
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.