The package is nothing more than a namespace. Within the package, there are sub-packages. The library contains a collection of related code capabilities that allows you to do a variety of activities without having to write your own code. A package is a collection of R functions, data, and generated code in the R programming language. The library is the site where the packages are kept.