Last updated Apr 14, 2021 2:55 PM
Maintaining a personal R library
You can install packages locally within your home directory using R. If you need a package quickly, on a one-time basis, or if the package is particularly specialized, you can install it locally using a personal library.
Installing random
The main function to install packages in R is “install.packages()”
It takes a vector of names of the packages you wish to install, and optionally, a destination library. It then downloads the packages from the repositories and installs them.
*If you do not specify a library to use, it will default to the first directory located in .libPaths() and a message if there is more than one.
For installs from a repository, R will attempt to install the packages in an order that respects their dependencies. This assumes that all the entries in lib are on the default library path for installs.
*Before installing packages, run ‘update.packages’ to ensure that any dependencies that are already installed are up to date to their latest versions.
To begin, type "R" into your terminal, after connecting to fiji-viz, to get into the R interpreter/shell.
After doing so, you should see a message like this one:
To install random, you want to use the same function mentioned above, install.packages()
You will then be asked if you would like to use a personal library instead, enter 'y' for yes. After, you will be asked if you'd like to create a personal library, followed by the name of the library. Enter 'y' for yes.
Then, it will ask for you to select a CRAN mirror for the session. You could use any of the ones listed, I chose to use 51: USA (CA 1) [https]. After you select a CRAN mirror, the installation will begin and complete. The returned message will tell you where the packages are stored in.
To ensure that the package was installed properly, use the library() function with the name of the package as the argument. If it was installed properly, nothing will be returned.