Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run an 'R' script without suppressing output?

Tags:

r

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?

like image 887
Hoa Avatar asked Mar 31 '12 20:03

Hoa


People also ask

Can you suppress output in R?

In this article, we are going to discuss how to suppress the output of a command in R programming language. Suppressing means making the output invisible. We can make the output should not appear. By using invisible() function we can suppress the output.

How do I run part of an R script?

Ctrl + Enter – Runs the current line and jumps to the next one, or runs the selected part without jumping further. Alt + Enter – Allows running code without moving the cursor to the next line if you want to run one line of code multiple times without selecting it. Ctrl + Alt + R – Runs the entire script.


1 Answers

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)

like image 75
daroczig Avatar answered Oct 22 '22 17:10

daroczig