Search⌘ K
AI Features

Getting Organized—Libraries and Working Directories

Explore how to manage R packages by installing, loading, and accessing help for them within your environment. Understand the importance of setting and organizing working directories to keep your scripts, data inputs, and outputs well-structured for efficient coding and project management.

By installing packages from CRAN, we can do everything from loading data directly from different sources to doing complex statistical analysis. We can create complex and exciting plots, maps, and animations, and even do machine learning.

In this lesson, we won’t discuss how to do all those things, but we’ll get familiar with how to work with packages in general, specifically:

  • Where to find them
  • How to install and load them
  • How to get help specific to a package

An R package is a set of functions that are developed and grouped together. For those who’re familiar with a more general-purpose programming language, they would be the equivalent of libraries in other languages. Each package we install in R will extend its capabilities along a particular theme by providing a suite of associated pre-built functions. Those functions are generic, so we can use them in our code without editing them. They will be directly applicable to our code.

Packages are our encyclopedias of functions
Packages are our encyclopedias of functions

Installing and loading packages in R

When it comes to packages in R, there are two things we need to check for:

  • Is the package installed?
  • Is the package loaded into my current environment?

Let’s take, for example, the dplyr package. The dplyr package is part of the tidyverse, a system for ...