1

I want to write comments, input and output of an R-script to a file. Writing input and output to the file seems to be working fine, but the comments don't show up.

How can I write the comments to a file as well?

I have a main script that runs another script with different settings. In the main script I run the other script with:

source("script.R", echo=T)

In "script.R" I write the output to a file with:

sink(paste(directory,"result.txt",sep=""),type=c("output","message"))

I then run the main script with:

Rscript --vanilla mainScript.R 
  • Welcome to SO. Your question is not reproducible. This may help http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. How are these "comments" done? `message()`? `warning()`? `print()`? `cat()`? Or, are they actual `#` comments? You haven't provided that info or even a bit of your `script.R`. – hrbrmstr Aug 12 '16 at 10:47
  • Form `?sink`: type = character string. Either the output stream or the messages stream... I always separate the two. – Christoph Aug 12 '16 at 14:55

0 Answers0