[Rd] How to understand packages, namespaces, environments

Alexander Stoddard astoddar at mail.med.upenn.edu
Fri May 6 18:45:03 CEST 2005

I would be very glad of pointers to information on how the concepts of 
packages, namespaces and environments are interrelated in R.

I am trying to get a handle on this both so I can delve further into 
understanding other people's code and so I can organize my own in a 
more coherent manner.

 From my reading about environments it seems they function as what I 
would intuitively call namespaces. However, the documentation for the 
'library' function implies that "namespace" has a specific meaning in R 
that I have so far failed to grasp. What is that meaning (or where 
should I look to read up on it) ?

I can think of the following more specific questions. Perhaps they may 
most usefully serve to reveal my misconceptions, so corrections would 
be very helpful.

Does saying the following load package 'foo' into its own environment ?
 > library(foo)

Do environments have names?

Of what does the list returned by search() actually consist? Is it a 
list of environments, a list that may include environments, or 
something else?

What is actually designated by a character vector of form "package:foo"?

In what ways can I use the character vector "package:foo" when 
interacting with R?

Many thanks,
Alex Stoddard

P.S. It took me a long time of flailing about to discover the 'search' 
function. Perhaps it could be included in the "See Also" section of the 
help for 'ls'.

More information about the R-devel mailing list