Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In R where does a variable named starting with a dot stores?

I am curious about variables named starting with a dot. e.g.

.var <- 100

It does not belong to the Global environment. What environment does this variable belong to?

like image 737
morningfin Avatar asked Jul 19 '16 01:07

morningfin


1 Answers

> ls(all.names = TRUE, envir = .GlobalEnv)
[1] ".Random.seed" ".var"         "a"   

Look at the man page for ls() by typing ?"ls" in the console

Below is the quote from the man page for all.names argument to be passed into ls(). The environment to look for can be controlled by the envir argument of ls command.

By default, ls(all.names = TRUE) will search for objects in the global environment.

all.names: a logical value. If TRUE, all object names are returned. If FALSE, names which begin with a . are omitted.

Also by passing the environment value to name argument, one can list all visible and hidden objects of that environment.

search()
ls(name = .GlobalEnv, all.names = TRUE)
ls(name = "package:base", all.names = TRUE)
like image 168
Sathish Avatar answered Sep 22 '22 02:09

Sathish