Reputation: 2605
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
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
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