Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created a eng_r function which exposes the R engine #1963

Merged
merged 17 commits into from
Mar 11, 2021
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export(combine_words)
export(current_input)
export(dep_auto)
export(dep_prev)
export(eng_r)
export(engine_output)
export(extract_raw_output)
export(fig_chunk)
Expand Down
19 changes: 19 additions & 0 deletions R/block.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,27 @@ block_exec = function(options) {
))
}
return(if (options$include) output else '')
} else {
eng_r(options)
}
}


#' Engine for R
#'
#' This function handles the execution of R code blocks (when the chunk option \code{engine} is \code{'R'})
#' and generates the R output for each code block.
#'
#' This engine function has one argument \code{options}: the source code of the current chunk is in \code{options$code}.
#' It returns a processed output which can consist of data frames (as tables), graphs or character output.
#' This function is intended for advanced use to allow developers to extend R,
#' and customise the pipeline with which R code is executed and processed within knitr.
#'
#' @param options A list of chunk options. Usually this is just the object
#' \code{options} associated with the current code chunk.

#' @export
eng_r = function(options) {
# eval chunks (in an empty envir if cache)
env = knit_global()
obj.before = ls(globalenv(), all.names = TRUE) # global objects before chunk
Expand Down
18 changes: 9 additions & 9 deletions man/Sweave2knitr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/all_labels.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/all_patterns.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/asis_output.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/chunk_hook.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions man/combine_words.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/eng_r.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions man/engine_output.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/fig_chunk.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/fig_path.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions man/hook_document.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions man/hook_plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions man/image_uri.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions man/imgur_upload.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions man/inline_expr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 21 additions & 23 deletions man/kable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/knit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions man/knit2html.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/knit_child.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/knit_engines.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/knit_expand.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading