knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of tee is to run R code in an isolated session, or arbitrary scripts, and log the output to a file. It is similar to the tee
utility, but relies on callr and processx. All systems where these packages work (including Windows) are supported.
Works for me.
You can install tee from GitHub:
# install.packages("remotes") remotes::install_local("krlmlr/tee")
The r_tee()
function has (almost) the same signature as callr::r()
but supports a tee
argument of type character
. If set, all output will be written to the file(s) specified in the tee
argument. Missing directories are created automatically.
library(tee) ret <- r_tee(function() { print("Hi!"); 42 }, tee = "log/hi.log") ret readLines("log/hi.log")
unlink("log", recursive = TRUE)
ANSI escapes will be stripped automatically from the output via fansi::strip_sgr()
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.