Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to log or record the output from R functions?

Tags:

r

Let's say I am running some code in R. As an example:

x <- 1

if (x == 0.1){
    print('X = 0.1')
    } else if (x > 0.1){
    print('X is bigger than 0.1 ')
    } else {
    print('X is smaller than 0.1')
    }

If I look at the history file in R studio it will show me that I ran this conditional statement but it will not show me the outcome (i.e. X is bigger than 0.1).

Is there a way to automatically log the output in R or R studio?

like image 226
Ido Hatam Avatar asked Dec 01 '15 18:12

Ido Hatam


1 Answers

Direct output to a log file and screen:

sink("myfilename", append=FALSE, split=TRUE)  # for screen and log

Return output to the screen only:

sink()

From Quick-R

like image 134
ddunn801 Avatar answered Nov 11 '22 00:11

ddunn801