# R Package Anatomy

Open-source R Packages running in the TERR engine are binary, and they must follow the standard package component design and contain version information.

The TERR engine is designed to be highly compatible with the open-source R engine. To develop packages using open-source R, see its documentation, available on the Comprehensive R Archive Network (CRAN).

Note: Open-source R is available under separate open source software license terms and is not part of TERR. As such, open-source R is not within the scope of your license for TERR. Open-source R is not supported, maintained, or warranted in any way by Cloud Software Group, Inc. Download and use of open-source R is solely at your own discretion and subject to the free open source license terms applicable to open-source R.

A typical package is available as a binary file or as source code. You can use TERR to install a package from source. If the package has C/C++ code, you must first install the package rinclude `(install.packages(rinclude)`) before calling `install.packages(packagename)`. TERR does not support installing packages that have Java source code. See Installation Options for Packages for more information.

## Package components

A source package can contain any number of directories, including html (for the help index), libs, help, and so on. The simplest package requires the following files and directories:

File or Directory | Description
--- | ---
mypkg | The top-level directory name, which is also the package name (in this case, mypkg).
mypkg/NAMESPACE | Required. You must specify the NAMESPACE.
mypkg/DESCRIPTION | The file containing a description, the title, the author, date, the dialect, and version information, along with other information.
mypkg/R | The directory containing *.R files with R language functions as ASCII files.
mypkg/R/mycode.R | The R language code.

Your source package can also contain the following optional folders:

- data directory containing data files in a dump format.
- man directory containing help files in the .Rd help file format.
- inst directory contains files and directories to be copied, recursively, into the main package directory when the package is compiled. Any informational files that the end user should see should be included in the inst directory. For example, if you have a PDF containing a vignette, you can include it in the inst/doc directory.
- src directory, containing C, C++, or FORTRAN code.
- tests directory can contain package-specific tests. This directory can contain test code (that is, .S, .ssc, .q, and .R).
  Note: The TERR engine does not support the following:
  - Packages using graphics devices or containing graphics functions. (However; we have implemented stub functions to allow the non-graphical portions of many packages to run without error.)
  - Source packages with src directories that contain Java code.

## Package versioning

Package version information is kept in the DESCRIPTION file. With every package revision, remember to revise the version number upward. This version number is an important part of your package management strategy.