
So that’s what installed means: it means “it’s on your computer somewhere”. So right now there are about 30 packages “installed” on your computer, and another 5000 or so that are not installed. 42 When you install R on your computer, you don’t get all of them: only about 30 or so come bundled with the basic R installation. As of this writing, there are just over 5000 R packages freely available “out there” on the internet.

However, before we get started, there’s a critical distinction that you need to understand, which is the difference between having a package installed on your computer, and having a package loaded in R. I’ll explain them as we go, because I think that helps you understand what’s going on. Along the way, you’ll see that whenever you get Rstudio to do something (e.g., install a package), you’ll actually see the R commands that get created. In this section, I’ll describe how to work with packages using the Rstudio tools, because they’re so much simpler. Fortunately, we don’t have to do things that way anymore. It’s not actually terribly hard to work with packages that way, but it’s clunky and unpleasant. When I first started writing this book, Rstudio didn’t really exist as a viable option for using R, and as a consequence I wrote a very lengthy section that explained how to do package management using raw R commands. Some packages are already installed when you put R on your computer, but the vast majority of them of R packages are out there on the internet, waiting for you to download, install and use them. A package is basically just a big collection of functions, data sets and other R objects that are all grouped together under a common name. In this section I discuss R packages, since almost all of the functions you might want to use in R come in packages.
