How do I get all the output from script I am running in RStudio

You can simply select the code you want to run and press CTRL+ENTER to do what you want in RStudio. This works for multiple lines, exactly like in Tinn-R. If you want to run everything at once in a verbose way, you press CTRL-A CTRL-ENTER.

As another option for saving to a text file, you can check ?sink :

sink(file='path/to/somefile.ext')
... # the code generating output
sink()

sink() redirects all output of the console to a connection, in this case some file. Mind you, this is only the standard output, not the warnings or errors. This command also come in handy to create output files in analyses, in combination with print(), cat(), sprintf() etc.

If you use "run all" in RStudio, you have to explicitly use any of the mentioned functions to generate the output to the file. In principle, RStudio runs silently if you run the whole script.


I'm one of the RStudio developers. Thanks for the feedback--I'll log a bug.

In the meantime, one workaround is to do source(filename, echo=T) from the console.


Use options(verbose=TRUE) to print all output verbosely throughout the script or session.

Tags:

Text

R

Rstudio