
devtools::load_all(): loads all functions in a package like when a package is installed and attached with library().usethis::create_package(): creates the file structure for a new package.The following functions are key for package development. The roxygen2 package allows us to easily create documentation for the functions and data contained in the packages.
To create an R package, we can use the devtools and usethis packages which include a variety of tools aimed at package development.
binary: single compressed file optimized for a specific OS. source: directory with subdirectories as above. The contents of a package can be stored as Other common parts include subdirectories data, tests and vignettes. NAMESPACE file that specifies exported functions that can be accessed by the users and imported functions from other packages. DESCRIPTION file with metadata for the package such as the name, version number and author. Subdirectory man that contains the documentation. Subdirectory R that contains R files with functions. The minimal requirements for an R package are the following: R packages are directories with subdirectories containing R functions, data, documentation and other information. R packages can be shared for reuse by others in several ways.įor example, they can be contributed to the Comprehensive R Archive Network (CRAN), put in GitHub, or distributed privately using files shares.
R packages provide a way to distribute R code, data and documentation.