| hal_excel | R Documentation |
Reads an .xlsx, treats columns without formulas as data, and translates
each formula column into a tidyverse expression via the active hal backend.
Returns a runnable R script – a line that reads the input columns from the
workbook plus a mutate() pipeline that recreates the formula columns – so
you can replace the spreadsheet (and the hal_excel() call) with the code.
hal_excel(path, sheet = 1, model = NULL, tolerance = NULL, retries = NULL)
## S3 method for class 'hal_excel_code'
print(x, ...)
path |
Path to an |
sheet |
Sheet name, or 1-based index (default |
model |
Optional model id; defaults to the session/configured model. |
tolerance |
Numeric tolerance for float comparison (default
|
retries |
Max self-correction attempts per column on mismatch (default
|
x |
A |
... |
Ignored. |
Works like hal_do() under the hood (disposable worker, code extraction,
denylist, timed eval, retry loop), with one addition: each translation is run
and checked against the values Excel cached, so only columns that match Excel
row-for-row go into the live pipeline; the rest are emitted as commented
stubs to review.
Each formula column is assumed to hold one formula filled down the column
(a vectorised expression, e.g. =A2*B2), so its first formula is translated
once. A workbook with no cached values is still translated but reported
unverifiable.
A hal_excel_code object (a character string of R code) that prints as
the generated script. The per-column report is attached as
attr(result, "hal_excel"). Save it with writeLines(result, "out.R").
## Not run:
hal_excel("model.xlsx") # prints the read + mutate script
code <- hal_excel("model.xlsx")
writeLines(code, "model.R") # or paste it in place of the call
attr(code, "hal_excel") # per-column verification report
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.