Webpage Table of Contents:
- RStudio
- Launching RStudio in Open OnDemand
- Working within RStudio
- Installing Packages
- Resuming Interrupted Sessions
- Exiting RStudio
- Limitations of Open OnDemand RStudio
- Troubleshooting
RStudio
RStudio is a powerful interactive environment dedicated to the R programming language. If you just want to use R, then see our R documentation (there are some critical differences in how to use R versus RStudio, including recommended processes to install packages). Otherwise, to utilize RStudio within Open OnDemand, follow these steps:
Make sure you don’t have any commands that produce output in your $HOME/.bashrc file. Run this command:
source $HOME/.bashrc
and observe if output is produced. If so, remove the command that produces output by editing the file $HOME/.bashrc.
Launching RStudio in Open OnDemand
- Once you have logged in to Open OnDemand, select Interactive Apps from the main menu and then click on "RStudio Server".
- Fill out the required session configuration form, an example is shown below in the screenshot:
-
The various parameters mean:
- Queue: Usually, this field can be left empty unless a specific queue needs to be selected.
- Number of hours: Indicates the duration for which the session will be active.
- Number of processors: Specifies how many processors the session will utilize.
- Exclusive Node Option: Requests exclusive access to a node; select multiple processors for scheduling, understanding that it may delay job initiation.
- Amount of memory requested: Specify memory requirements, such as “1GB” for one gigabyte.
- Version of R container: Select the appropriate R version for the session.
- Working Directory for RStudio: Define the directory where you want your files to be stored. Before creating a new session, ensure the directory exists.
- Path to User Libraries: Define where user-installed libraries are stored.
- After finalizing the configuration, click on the Launch button. Job initiation time may vary based on resource allocation. Once ready, select the Connect to RStudio Server button to access the RStudio application.
Working within RStudio
Upon clicking the Connect to RStudio Server button, the RStudio application interface will appear, offering familiar functionalities and features. Files created in the session will be saved in the directory specified in the configuration form.

Users are encouraged to utilize RStudio as they typically would in local environments with a few caveats.
Installing Packages
RStudio is particular regarding packages, i.e., the version of the packages installed must align with the version of RStudio running. The RStudio in Open OnDemand is served by a container. Therefore, the recommended way of installing packages for RStudio in Open OnDemand is to install them from within a shell inside the RStudio container. This assures maximum compatibility of the packages with the RStudio container running in Open OnDemand
Furthermore, the packages should be installed somewhere other than home (which is easy to do by specification in $HOME/.Rprofile), given that the home directory has limited space. The suggested location for these package installations varies depending on if you are performing work under a HPC Research Project (e.g., an account created by a professor for their research work), or a HPC Course Project (a HPC project created for a specific course for a specific semester, e.g., e298s26).
The generic path /path/to/rpkgs will be used below as a placeholder in the documentation below. Fill in the appropriate path depending on what type of HPC Project you are working under, as detailed below.
HPC Research Project Path for Packages
/usr/local/usrapps/<group>/<username>/rpkgs OR Research Storage, e.g., /rs1/researchers/<first_letter_of_PI_user_name>/<user_name of PI>/rpkgs
HPC Course Project Path for Packages
/share/<HPC_Course_Project_name>/<username>/rpkgs
Detailed directions for installing packages for RStudio
- From a HPC (Hazel) login node, make the directory to hold the R packages
mkdir /path/to/rpkgs
- Edit the file
$HOME/.Rprofileso that .libPaths has the path to where you want to install packages, e.g., put this line in the file. WARNING: the below will replace any existing paths in your .libPaths..libPaths(c("/path/to/rpkgs")) #WARNING: It is important NOT to use $GROUP, $USER, and other environment variables in this .libPaths() specification - In your home directory (
cd $HOME), create a file with all the R packages you want, i.e., just the name of each package on each line. Call the filemy_r_libs.txt. - Use apptainer to start up the RStudio container of interest, with shell interaction, and binding appropriate path. Here we will use version 4.4.0 of the RStudio container. Then, start up the R session. See below commands.
module load apptainer apptainer shell --bind $HOME,/path/to/rpkgs /usr/local/apps/ood/images/rstudio-v4.4.0.sif cd $HOME R
- Now issue install.packages commands from within the R session, using the list of packages we want to install that is in the file
$HOME/my_r_libs.txt.getwd() # ensure this is $HOME, i.e., /home/<username> .libPaths() # ensure this has /path/to/rpkgs as the first path file_path <- "./my_r_libs.txt" lines_vector <- readLines(file_path) for (line in lines_vector) { print(sprintf("Installing %s",line)) install.packages(sprintf("%s",line)) } #NOTE: as each package is installed, ensure that it is installing into the correct location (not your home space, which is limited in size), e.g., look for the language "Installing package into ‘/path/to/rpkgs'" - Once the R commands above are done executing, you should have all the packages installed! You can check the output of the final command above (install.packages…) for words like "Warn" or "Error" to see if there were problems. Assuming all went well, now we must tell RStudio to use that library path when it starts up in Open OnDemand. When entering specifications for RStudio into Open OnDemand, put the string:
/path/to/rpkgsinto the field "Path to User Libraries"
Also make sure to choose the same RStudio container (“Version of R Container” field) that you used to install the packages (4.4.0 in this example). See screenshot below.
- Now, once you Launch RStudio, you should be able to load any of the packages you installed, e.g., type:
library(<name of package>). Once in RStudio, you may want to type.libPaths()to double make sure your/path/to/rpkgsis there.
Resuming Interrupted Sessions
In instances where your session is still active, you can re-establish the connection (useful in case of broken connections) via the My Interactive Sessions menu.
Any currently running sessions will be listed, and users can reconnect by clicking the Connect to RStudio Server button.
Exiting RStudio
To properly exit your RStudio session, follow these steps:
- Click the Power button located in the RStudio interface.
- Close the RStudio window to end your session.
- Finally, back in the My Interactive Session window, click the Delete option to remove the session from active job listings.
Limitations of Open OnDemand RStudio
While Open OnDemand with RStudio offers substantial advantages, it does come with inherent limitations, including:
- Limited Internet Connectivity: Not all websites and services may be accessed, impacting functionalities that rely on external resources.
- Restricted CRAN Mirrors: Access to CRAN mirrors is limited, which may affect package installations. See Installing Packages section for the recommended process for installing packages.
- Potential Configuration Conflicts: Some of the user configurations from local environments may clash with the Open OnDemand version settings, leading to unexpected behaviors.
- Missing Full Internet Connection Resources: Certain components, particularly those requiring a full internet connection such as the Connections panel (ODBC, Spark), may encounter errors or be non-operational.
- Inability to Install Certain R Packages: Packages that have compiled components, such as shiny or learnr, cannot be installed due to absent dependencies and components required for configuration.
Troubleshooting
502 Errors
If you encounter a 502 Proxy error, it is advisable to check the connection speed of your account logins via the SSH Shell. Slow login times can often lead to Open OnDemand timeout issues. A common culprit is the inclusion of certain commands within the .bashrc file, which may significantly delay login speeds.
For example, users who have added code for conda may need to remove the code from the .bashrc file and relocate it to an alternative file, such as .conda.bashrc, for efficient sourcing when necessary.
RStudio Will Not Launch Properly from Open OnDemand
First, delete all your RStudio jobs in Open OnDemand. Then, from a login shell, try issuing these commands to clear out some configuration directories:
mv $HOME/ondemand $HOME/ondemand.old # we are not deleting this directory just in case it has files you need. It probably does not, but it is worth it to be extra careful. # Next time you use Open OnDemand, a new $HOME/ondemand directory will be automatically created. # You can delete $HOME/ondemand.old once you are sure it contains nothing you need.
mv $HOME/.local/share/rstudio $HOME/.local/share/rstudio.old # we are not deleting this directory just in case it has auto-saved RStudio files you need. It probably does not, but it is worth it to be extra careful. # Next time you use RStudio in Open OnDemand, a new $HOME/.local/share/rstudio directory will be automatically created. # You can delete $HOME/.local/share/rstudio.old once you are sure it contains nothing you need.
mv $HOME/.config/rstudio $HOME/.config/rstudio.old # we are not deleting this directory just in case it has files you need. It probably does not, but it is worth it to be extra careful. # Next time you use Open OnDemand, a new $HOME/ondemand directory will be automatically created. # You can delete $HOME/.config/rstudio once you are sure it contains nothing you need.
Now try launching RStudio from Open OnDemand again.
If you still have an error, please navigate in Open OnDemand to "My Interactive Sessions" in the top menu bar, then find the RStudio Server session that failed. Now click on the link next to "Session ID:", then scroll down to the "output.log" file. Download “output.log”, and attach it to an email you send to help@ncsu.edu
RStudio Will Not Respect the Path You Supplied for User Libraries
If you enter the library path /path/to/rpkgs in "Path to User Libraries" field in Open OnDemand, and .libPaths() issued from RStudio still does not show that path, then try this command (after deleting all your RStudio jobs in Open OnDemand):
mv $HOME/.local/share/rstudio $HOME/.local/share/rstudio.old # we are not deleting this directory just in case it has auto-saved RStudio files you need. It probably does not, but it is worth it to be extra careful. # Next time you use RStudio in Open OnDemand, a new $HOME/.local/share/rstudio directory will be automatically created. # You can delete $HOME/.local/share/rstudio.old once you are sure it contains nothing you need.
Also, note that settings in your $HOME/.Renviron and $HOME/.Rprofile files sometimes alter the library path. These files generally take precedence over any other alterations to the library path.
The RStudio Working Directory
You can set your starting working directory in the Open OnDemand RStudio interactive application settings. Within RStudio, you may issue setwd(‘/path/to/dir’) to change directory, and getwd() to get current working directory. The three dots in the file tree browser (upper right) allow you to change directory in the file tree browser. Just type the full path in, e.g., /share/<group>/<username>. Note, the working directory in the console is sometimes different than in the file tree browser.
If you have multiple RStudio sessions running concurrently (multiple Open OnDemand jobs), then the working directory can become unpredictable. If you refresh the browser page a couple of times for each RStudio session, the issue should be resolved. Still, in general, it is not a good idea to have multiple RStudio sessions running concurrently.
Last modified: September 01 2026 21:22:40.