R

Use R Markdown

Write reproducible R reports with Markdown prose, R chunks, plots, and rendered output.

What R Markdown is for

R Markdown combines prose, R code, output, and document rendering in one file. Use it for reports, statistical notebooks, teaching materials, and reproducible analysis that should render to HTML, PDF, or other formats.

Create and render

  1. Create a .Rmd file.
  2. Put document settings in the YAML header.
  3. Write Markdown prose.
  4. Add R chunks for computations, plots, tables, and checks.
  5. Render the document and inspect the output.

Run chunks incrementally while developing. If a full render fails, rerun the failing chunk in a fresh session and check package availability in the project environment.

Ask Agent to repair a render failure

A failed R Markdown render can offer Fix with Agent... below the error output when AI help is available. Use that control to carry the render failure into an agent conversation.

  1. Render the document and inspect the error output in the Build Log.
  2. Choose Fix with Agent.... If you want debugging guidance first and the option is available, choose Ask Agent for a Hint....
  3. Review the error context in the confirmation and select a recent agent session when shown.
  4. Confirm with Send to Agent or Ask Agent, then follow the request in the agent chat.
  5. Inspect any changed source and render the document again to check the result.

The request includes the render error and build command. When the log identifies a source-line range, that range is also supplied. The agent is directed to read the live document before editing. Ordinary informational output from a successful render does not trigger this failed-build shortcut.

Reproducibility

Keep package setup, data paths, and rendering commands explicit. For classes or shared research projects, prefer a runtime image or setup script so the R environment is reproducible across projects.