Why are my R packages not installing correctly when using RStudio on Open OnDemand on Cheaha?

I am attempting to install packages into my R environment using RStudio in Open OnDemand on Cheaha. When I do, I receive errors about failed compilation and the package is not installed. Why is this happening and what can be done about it?

When using the RStudio Server app (the non-deprecated version) on Open OnDemand, some packages that need C++ compilation will not install correctly when run directly from either the RStudio console or the Install Packages button. As a temporary workaround, you can install the packages from the terminal inside RStudio.

  1. Select the Terminal tab next to the Console tab.

  2. Load the same R module you loaded when requesting the session using the module load R/<insert version> command.

  3. Start R using the R command.

  4. Install the packages you need using R’s install.packages command (or whichever other package installer you need, such as BiocManager::install).

    • For some people, the utils package may not be loaded initially causing R to not be able to find the install.packages command. Use library(utils) first, then use install.packages.
  5. Once your packages are installed, close the terminal by clicking the dropdown and selecting Close Terminal. This will free the resources the terminal R session was using for RStudio to be able to use again.

    Close the R Terminal

Your R packages should now be available for use.