Skip to contents

Write the human-readable rendering of a writeup, review or AI review to a file: the text print shows, laid out for a document. write_result writes the same objects as JSON documents for programs to read.

Usage

write_text(x, file, format = NULL, overwrite = FALSE, verbosity = 1L, ...)

Arguments

x

SupervisedWriteup (from writeup), SupervisedReview (from review) or AISupervisedReview (from ai_review) object.

file

Character: Path of the file to write.

format

Optional Character {"markdown"}: Output format. NULL selects the format from the extension of file: ".md" or ".markdown" for Markdown.

overwrite

Logical: If TRUE, replace an existing file.

verbosity

Integer: Verbosity level.

...

Not used.

Value

The path of the file written, invisibly.

Details

Markdown output starts at ## headings and uses pipe tables, ready to convert with Pandoc or Quarto or to paste into a manuscript.

Author

EDG

Examples

idx <- c(1:40, 51:90, 101:140)
mod <- train(
  iris[idx, ],
  dat_test = iris[-idx, ],
  hyperparameters = setup_CART(),
  verbosity = 0L
)
#> Error in UseMethod("train"): no applicable method for 'train' applied to an object of class "data.frame"
write_text(writeup(mod), file.path(tempdir(), "writeup.md"))
#> Error: object 'mod' not found
write_text(review(mod), file.path(tempdir(), "review.md"))
#> Error: object 'mod' not found