R packages are the fundamental unit of shareable code. These packages bundle together code, data, documentation, and tests that can be easily shared and replicated by others. The Comprehensive R Archive Network or CRAN, hosts close to ten thousand of these user-contributed packages, making them available to all users for installation and use.
Individual packages have various purposes. Some of these include importing and transferring data from other programs into a readable format in R, allowing users to import data directly from APIs (Application Program Interface), or changing the layouts of datasets for a tidier appearance. Overall, the main purpose of packages is to provide users with preexisting code to save time and effort when working in R and RStudio.
Installing packages into R and RStudio can be done in two ways. The first sep for both is to select the package you wish to install. This can be done from CRAN (https://cran.r-project.org/web/packages/). This RStudio page also provides a list of suggested CRAN packages that may be useful to install.
Since R is command line only, there is one option when installing a package into R; using the function install.packages()
. In the command line, type:
In RStudio there are two methods to install a package. This first is the same as above, using the install.packages()
function. Again, in the command line, type:
The second option is using the user interface of RStudio. This option requires more steps, but those less comfortable with coding may find it more intuitive. However, we urge you to first try using the command line to install packages before referring to this option, as using the command line will assist in increasing your level of comfort with the R language.
The following is a list of packages that will be used throughout the University of Oregon Libraries' R Workshop Series. For those attending the workshop, instructors will assist in installation of the appropriate packages. For those who are unable to attend but wish to walk-through the provided materials on their own, please install the following packages using the instructions provided above. As a reminder, the function install.packages("name_of_package")
can be used to install packages in both R and RStudio.