How do you install packages in R? (Windows)
- Make sure you know the name(s) of your package(s).
- Open R. You should see an R Console.
- Select Packages from the drop down menu. Choose Install package(s)...
- You will be asked to choose a mirror. Choose a location that is near your area. Of course, the default 0-Cloud should be ok.
- If you run into speed problems, it might be a good idea to choose a different mirror.
- Click Ok and then Packages will pop up. Select the packages you need.
- If you need multiple packages, you have to hold the Shift key and click on the appropriate packages. Alternatively, you can install packages one at a time.
- You will be asked "Would you like to use a personal library instead?" Choose yes for this question, and yes again for the next question (might be relevant for new users).
How do you install packages in R? (macOS)
- Make sure you know the name(s) of your package(s).
- Open R. You should see an R Console.
- Select Packages & Data from the drop down menu. Choose Package Installer.
- You will be asked to choose the Packages Repository and Install Location.
- Choose CRAN (binaries) as your Packages Repository. Click on Get List. You will be asked to choose a mirror. Choose a location that is near your area. 0-Cloud should be also ok.
- Select the packages you need. If you need multiple packages, you have to hold the Shift key and click on the appropriate packages. Alternatively, you can install packages one at a time.
- Choose At User Level as your Install Location. Put a check for Install Dependencies.
- Once you are done, click Install Selected.
How do you load packages in R? (Windows and macOS)
- Make sure you know the name(s) of your package(s). Suppose the name is name-of-package.
- Open R. You should see an R Console.
- Type in library(name-of-package) and press enter.
- If you encounter an error, it is likely you have not installed the package. You may encounter warnings, but these depends on the package.