When doing load("files.RData"); ls()
the output printed to the console is:
'File1' 'File2' 'File3'
When doing (load("files.RData"))
(the point of the parentheses around load()
being to indicate to R to print the output of that line) the output printed to the console is:
'.Random.seed' 'File1' 'File2' 'File3'
Question: What is the reason for this difference?
Note: This might be specific to IRkernel since this code is being run in a Jupyter notebook.
From
help("ls")
, we can see the purpose of theall.names
argument tols()
, which has a default value ofFALSE
:So, in your first example,
ls()
will not print.Random.seed
; it begins with a.
.Now let us consider the "Value" sections of the help files for
load
:and
Paren
:So, in your second example,
load("files.RData")
invisibly returns "A character vector of the names of objects created" (even.Random.seed
), but(
auto-prints that character vector, even including.Random.seed
.What even is
.Random.seed
?First, we can see what it is by looking at
help(".Random.seed")
:It will pop up in your global environment any time you use one of R's pseudo-random number generators. For example, in a fresh R session, I can do the following:
Then I can save any or all of these R objects via
save()
:If I use
save.image()
, everything in my global environment is saved, even files beginning with.
-- according to the help file, it's a shortcut forsave(list = ls(all.names = TRUE), file = ".RData", envir = .GlobalEnv)
.So, wherever you got the
files.RData
from, they either usedsave.image()
, or intentionally included their.Random.seed
object when savingfiles.RData
.