| Title: | Write Printed Output of R Objects to Log Files |
|---|---|
| Description: | Provides writeLog(), a small helper that writes the printed output of a named list of R objects to a text file in a log directory, one element after another, each preceded by its list name as a heading. Supports versioned file names and appending to an existing log file. |
| Authors: | Jeffzifan Wu [aut, cre] |
| Maintainer: | Jeffzifan Wu <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-15 20:52:00 UTC |
| Source: | https://github.com/cran/writeLog |
Write the printed output of each element of a named list to a .txt file in logDir, one after another, each preceded by its list name as a heading.
writeLog( x, fileName = "log", version = NULL, desc = NULL, logDir, append = FALSE )writeLog( x, fileName = "log", version = NULL, desc = NULL, logDir, append = FALSE )
x |
Named list of objects to print/log, e.g. list(int.orig = summary(int), int.hp = halvorsenPalmquist(int)). |
fileName |
Name of the log file, without extension (e.g. "aq_bdr"). |
version |
Version label prepended to fileName (e.g. "v1"). The file is written as logDir/version_fileName.txt; if NULL, the version prefix and its separator are dropped. |
desc |
Description to print at the top of the log file. |
logDir |
Directory to write the log file to, e.g. tempdir(). Created if missing. There is no default, so the package never writes to the working directory or home filespace unless you ask it to. |
append |
If TRUE, add to the log file when it already exists rather than overwriting it; if it does not exist, a new file is created. If FALSE (the default), any existing file is overwritten. |
x, invisibly (so this can be used inline without breaking a pipe).
tmp <- tempfile() writeLog(list(one = 1:3, summary = summary(1:10)), fileName = "example", logDir = tmp) readLines(file.path(tmp, "example.txt"))tmp <- tempfile() writeLog(list(one = 1:3, summary = summary(1:10)), fileName = "example", logDir = tmp) readLines(file.path(tmp, "example.txt"))