How to knit directly to R object?
问题 I'd like to store a knit() ted document directly in R as an R object, as a character vector . I know I can do this by knit() ing to a tempfile() and then import the result, like so: library(knitr) library(readr) ex_file <- tempfile(fileext = ".tex") knitr::knit(text = "foo", output = ex_file) knitted_obj <- readr::read_file(ex_file) knitted_obj returns # [1] "foo\n" as intended. Is there a way to do this without using a tempfile() and by directly "piping" the result to a vector? Why on earth