Provides support for executing SLC code blocks in Quarto documents. This function is automatically called by knitr when processing SLC code chunks.
Arguments
- options
A list of chunk options from knitr, including:
- code
Character vector containing the SLC code to execute
- input_data
Name(s) of R data.frame(s) to make available in SLC. Can be a single name or comma-separated names (optional)
- output_data
Name(s) for capturing SLC output data into R. Can be a single name or comma-separated names (optional)
- eval
Whether to evaluate the code (default: TRUE)
- echo
Whether to show the code (default: TRUE)
- include
Whether to include output (default: TRUE)
Details
This function handles the execution of SLC code within Quarto documents by:
Initializing SLC connection if needed
Transferring input data from R to SLC if specified
Executing the SLC code
Capturing output and logs
Transferring output data from SLC to R if specified
Multiple datasets can be specified using comma-separated names:
input_data="df1,df2,df3"- transfers multiple R data.frames to SLCoutput_data="result1,result2"- captures multiple datasets from SLC to R
Global Environment Assignment
When output_data is specified, this function intentionally assigns
the resulting dataset(s) to the global environment using assign(..., envir = .GlobalEnv).
This is the expected behavior to make SLC output data available for subsequent
R code chunks in the same Quarto document.
Examples
if (FALSE) { # \dontrun{
# This function is typically called automatically by knitr
# when processing SLC code chunks in Quarto documents
# Example chunk options that would be passed:
options <- list(
code = c("data test;", " x = 1;", "run;"),
input_data = "mtcars",
output_data = "results",
eval = TRUE,
echo = TRUE
)
# Multiple datasets example:
options <- list(
code = c("data combined;", " set df1 df2;", "run;"),
input_data = "df1,df2",
output_data = "combined,summary",
eval = TRUE,
echo = TRUE
)
# The engine would be called like this:
# slc_engine(options)
} # }