13

At the moment I have a very simple script. If I type the commands into a console, I have text printing to the screen. However if I run the script using the following

source('myscript.R')

The contents are executed but nothing is printed to the screen. How do I stop console output from being suppressed?

Hoa
  • 19,858
  • 28
  • 78
  • 107

2 Answers2

17

IMHO you need to specify print.eval parameter set to TRUE if you want to get only the output (and not the commands). If you would need the commands too, you should set echo to TRUE (which implies setting print.eval to TRUE).

For example:

source('myscript.R', print.eval = TRUE)

daroczig
  • 28,004
  • 7
  • 90
  • 124
-1

Use sink() to bring back the r console output as normal

kamran kausar
  • 4,117
  • 1
  • 23
  • 17