These functions use the active LLM to assist with writing and reviewing R Markdown and Quarto documents. Each call uses an isolated chat context.

  • llm_review_document() reviews a document for language, structure, or completeness and returns Dutch-language feedback.

  • llm_write_section() writes a Dutch section (e.g. Methods, Results) for a report, presentation, or article.

  • llm_write_chunk() generates or improves an R code chunk for a document.

llm_review_document(
  file = NULL,
  text = NULL,
  focus = c("all", "language", "structure", "completeness"),
  new = FALSE,
  ...
)

llm_write_section(
  section,
  data = NULL,
  context = NULL,
  style = c("report", "presentation", "article"),
  new = FALSE,
  ...
)

llm_write_chunk(code = NULL, goal = NULL, new = FALSE, ...)

Arguments

file

Path to an .Rmd or .qmd file. The first 3000 lines are read. Either file or text must be supplied.

text

The document content as a character string. Either file or text must be supplied.

focus

What to focus on during review: "language", "structure", "completeness", or "all" (default).

new

Logical. If TRUE, re-initiates the LLM before the task call. Default is FALSE.

...

Additional arguments passed to the LLM chat method.

section

Name of the section to write, e.g. "Methods", "Results", "Discussion".

data

Optional data frame providing context for the section. Summarised before sending to the LLM.

context

Optional character string with additional background context for the section (e.g. a description of the analysis).

style

Document style: "report" (default), "presentation", or "article".

code

Optional existing R code to improve (as a character string).

goal

Description of what the code chunk should accomplish. Required when code is NULL.

Value

A character string with the generated or reviewed text.