[R] Missing information in source()

William Dunlap wdunlap at tibco.com
Tue Nov 7 21:32:35 CET 2017


Either change your script by adding print(...) calls where you want to see
something printed or change the call to source() by adding print.eval=TRUE
or echo=TRUE.   E.g.,

> cat(file = tf <- tempfile(), "head(10:1)\ntail(letters)\nx <-
gamma(0:4)\nx\n")
> source(tf)
Warning message:
In gamma(0:4) : NaNs produced
> source(tf, print.eval=TRUE)
[1] 10  9  8  7  6  5
[1] "u" "v" "w" "x" "y" "z"
[1] NaN   1   1   2   6
Warning message:
In gamma(0:4) : NaNs produced
> source(tf, echo=TRUE, print.eval=TRUE)

> head(10:1)
[1] 10  9  8  7  6  5

> tail(letters)
[1] "u" "v" "w" "x" "y" "z"

> x <- gamma(0:4)

> x
[1] NaN   1   1   2   6
Warning message:
In gamma(0:4) : NaNs produced
>

Calling options(warn=1) before calling source() will keep the warnings near
the lines that caused them.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Nov 7, 2017 at 12:01 PM, Tom Backer Johnsen <Backer at uib.no> 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?
>
> Tom Backer Johnsen
> University of Bergen
> Norway
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list