[R] package question

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Jan 25 09:23:21 CET 2004


Look more closely at the section on `Package name spaces'.

  R has a name space management system for packages. This system allows
  the package writer to specify which variables in the package should be
  exported to make them available to package users ....

Alternatively, you can manage this yourself by using lexical scope:
if you define variables and functions in a local() block (and make sure 
the functions are visible) the variables will be visible only to those 
functions.  There are examples of that in the source file 
src/library/base/R/zdynvars.R (and elsewhere).


On Sun, 25 Jan 2004, Christian Lederer wrote:

> is it possible, to define variables, which are only
> visible to functions belonging to a certain package?
> (For a certain package i would like to have something
> similar to static variables in C, which are only visible
> to functions defined in the same source file.)
> 
> In the documentation (``Writing R Extensions") i found
> nothing appropriate.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list