R is a bare bones program. Its utility comes from the 3500+ packages available for installation. You may think of these packages as similar to extensions or apps, which some other programs use, like Google, Chrome or Apple products. Each package serves a purpose and has specific commands you can use. In short, Packages are user-created programs which can be used to run a specific task or set of tasks.
Using packages is a twostep process. First you must install the package you want, and then you must load it into R.
>install.package(“nameofpackage”) # installs a package
>library(“nameofpackage”) # loads an already installed package, you can use a package only after loading it
>installed.packages() # lists installed packages (not necessarily loaded)
One can install multiple packages at once with a single call by placing the names of the packages in a character vector.
install.packages(c(“tidyr”, “devtools”, “dplyr”, “ggplot2”))
R (and RStudio) employs the notion of a global working directory.
Any workspace images (.RData files) are stored here. Data can be imported into R directly from the working directory, without specifying the complete path of the file name.
There are 2 functions in R to get and set the working directory location.
getwd() # returns current working directory
setwd(“/path/to/new/working/directory”) # changes current working directory