[R] Missing information in source()
murdoch.duncan at gmail.com
Tue Nov 7 21:33:29 CET 2017
On 07/11/2017 3:01 PM, Tom Backer Johnsen wrote:
> Dear R-help,
> I am running a Mac under Sierra, with R version 3.4.2 and RStudio 1.1.383. When running head () or tail () on an object in a script using source (<script name>) nothing appears in the output file, but if I use these commands in the normal R window the normal output appears.
> What am I doing wrong?
You aren't printing the results. source() has an argument "print.eval"
which defaults to FALSE; you can change it. A common way to do that is
to set echo=TRUE, but echoing the input is not necessary.
source(filename, echo = TRUE)
for a lot of output, or
source(filename, print.eval = TRUE)
for somewhat less.
In most cases an explicit print() will be needed if the head() or tail()
is in a loop or in a function.
More information about the R-help