pipe - How to knit directly to R object? -
i'd store knit()ted document directly in r r object, character vector.
i know can knit()ing tempfile() , import result, 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 way without using tempfile() , directly "piping" result vector?
why on earth want this, ask?
*.texstring programmatically saved disc, , rendered pdf later. reading rendered*.texdisc in downstream functions make code more complicated.- caching whole lot easier, , moving cache different machine.
- i scared of side effects in general , file system shenanigans across machines/oses in particular. want isolate few (
print(),save(),plot()) functions possible.
does make me bad (or ocd) r developer?
it should straightforward single line this:
knitted_obj = knitr::knit(text = "foo") you may want read page ?knitr::knit again know returns.
Comments
Post a Comment