Fortranner
Fortranner

Reputation: 2605

Show R commands interspersed with output

I can run an R script with source("foo.r") but just see the output. Is there an option to have the lines of the script being run interspersed with the output?

Upvotes: 0

Views: 100

Answers (2)

Noam Ross
Noam Ross

Reputation: 6229

The knitr package can create a report that includes the script interspersed with output and plots:

library(knitr)
stitch("my_script.R")

stitch produces a PDF using LaTeX by default. You can get your output as HTML or as markdown/plain text with stitch_html and stitch_rmd.

Upvotes: 1

David Marx
David Marx

Reputation: 8558

Try playing with the echo and verbose parameters. You can get more details on how to modify the function's behavior by executing ?source, which should give you the documentation for the function.

Upvotes: 6

Related Questions