(R-ints.info)Package Structure


Next: Files Prev: Internationalization in the R sources Up: Top
Enter node , (file) or (file)node

4 Structure of an Installed Package
***********************************

Metadata
Help
The structure of a _source_ packages is described in Note: Creating R
packages.: this chapter is concerned with
the structure of _installed_ packages.

   An installed package has a top-level file 'DESCRIPTION', a copy of
the file of that name in the package sources with a 'Built' field
appended, and file 'INDEX', usually describing the objects on which help
is available, a file 'NAMESPACE' if the package has a name space,
optional files such as 'CITATION', 'LICENCE' and 'NEWS', and any other
files copied in from 'inst'.  It will have directories 'Meta', 'help'
and 'html' (even if the package has no help pages), almost always has a
directory 'R' and often has a directory 'libs' to contain compiled code.
Other directories with known meaning to R are 'data', 'demo', 'doc' and
'po'.

   Function 'library' looks for a namespace and if one is found passes
control to 'loadNamespace'.  Then 'library' or 'loadNamespace' looks for
file 'R/PKGNAME', warns if it is not found and otherwise sources the
code (using 'sys.source') into the package's environment, then
lazy-loads a database 'R/sysdata' if present.  So how R code gets loaded
depends on the contents of 'R/PKGNAME': a standard template to load
lazy-load databases are provided in 'share/R/nspackloader.R'.

   Compiled code is usually loaded when the package's namespace is
loaded by a 'useDynlib' directive in a 'NAMESPACE' file or by the
package's '.onLoad' function.  Conventionally compiled code is loaded by
a call to 'library.dynam' and this looks in directory 'libs' (and in an
appropriate sub-directory if sub-architectures are in use) for a shared
object (Unix-alike) or DLL (Windows).

   Subdirectory 'data' serves two purposes.  In a package using
lazy-loading of data, it contains a lazy-load database 'Rdata', plus a
file 'Rdata.rds' which contain a named character vector used by 'data()'
in the (unusual) event that it is used for such a package.  Otherwise it
is a copy of the 'data' directory in the sources, with saved images
re-compressed if 'R CMD INSTALL --resave-data' was used.

   Subdirectory 'demo' supports the 'demo' function, and is copied from
the sources.

   Subdirectory 'po' contains (in subdirectories) compiled message
catalogs.


automatically generated by info2www version 1.2.2.9