Last updated Mar 26, 2020 11:56 AM
Installing R Packages from Source
While working with R, typically packages are installed using CRAN. However, sometimes you run into an issue where you're using a specific version of R and need an older (or newer, development) version of a package. There isn't a way to instruct CRAN to install an old version. What you can do instead is go to the package's overview page on CRAN, for example: https://cran.r-project.org/web/packages/caTools/index.html, and look for the line that says "Old sources." Click on the archive link, and you should see several versions of the package, like this:
![screenshot_cran.png](/media/images/2020-03-26-112911_929x1039_scrot.width-800.png)
Unfortunately, there is usually no great way to tell which versions of which package are compatible with which R version (try saying that 10 times fast!). The best way to handle this is to download several versions, starting with the NEWEST. Copy the link location for the newest version of the package you're trying to install, as you will need it for the next step. Login to Fiji however you normally do, and you should be at a command prompt. Use wget to download the source by pasting the link from before, noting which directory you're running the command from, as this is where the file will get downloaded to:
Next, open whichever version of R you are trying to install your package for. If you are using Rstudio-server on Fiji, it will always be the system version, meaning you have not used module load to change your R version. You should just see information about R and a blank prompt:
Lastly, we can still use install.packages()
to install from source, we just have to manually specify where the file is. Be sure to change the path and filename accordingly for your use case!