[Rd] Startup process: Objects are automatically print():ed

Henrik Bengtsson henrik.bengtsson at gmail.com
Mon Dec 19 17:55:10 CET 2016


Consider a `~/.Rprofile` file containing:

print("hello")
"world"
invisible("!")

This will output the following:

[1] "hello"
[1] "world"

when R is started.  Note that "world" is also print():ed.  In
contrast, if you'd source() the same file, then you'd need to use
argument print.eval = TRUE to get the same behavior:

> source("~/.Rprofile")
[1] "hello"
> source("~/.Rprofile", print.eval = TRUE)
[1] "hello"
[1] "world"
```

I am aware that the R startup process is special in many ways, e.g. it
happens very early on and only the base package is loaded.  However,
is the automatic print():ing of objects by design, a side effect, or a
bug?  It appears to not be documented, at least not in help("Startup",
package = "base").

/Henrik

PS. I've got a bit of a deja vu while writing this - I might have
already brought this one up many years ago.

> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base



More information about the R-devel mailing list