> For the complete documentation index, see [llms.txt](https://docs.ccv.brown.edu/stronghold/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ccv.brown.edu/stronghold/software/linux-standard-software/rstudio.md).

# RStudio

These instructions are for using **RStudio** on the Stronghold Linux workstation. If you prefer to use **R directly from the terminal** to install packages using [**CRAN**](/stronghold/software/mirrors/cran-mirror.md) or [**Bioconductor**](/stronghold/software/mirrors/bioconductor-mirror.md) mirrors, please refer to the corresponding documentation link.

When working with the **RStudio interface**, the key difference is that you need to:

1. Load <mark style="color:$danger;">**both**</mark> the `r` and `rstudio` modules, and
2. Launch RStudio using the `rstudio` command.

Detailed instructions for different package sources and R versions are provided below.

## 1. Using the CRAN Mirror

If you want to install packages from the **CRAN mirror**, run the following commands:

1\) Load the R and RStudio modules into your current environment.

```bash
module load r rstudio
```

2\) Launch the RStudio interface.

```bash
rstudio
```

3\) Install the R package you specify (replace `<package_name>` with the actual name of the package) using Brown University’s CRAN mirror for faster access and reliability.

```r
install.packages("<package_name>", repos="http://cran.services.brown.edu")
```

## 2. Using the Bioconductor Mirror

If you need to install packages from **Bioconductor**, use the following commands:

1\) Load the R and RStudio modules into your current environment.

```bash
module load r rstudio
```

2\) Launch the RStudio interface.

```bash
rstudio
```

3\) Disable Bioconductor’s online version diagnosis (to avoid network-related conflicts), then install and use the **BiocManager** package to install your desired package(s).

```r
BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS = FALSE
install.packages("BiocManager")

BiocManager::install(c("<package_name>"))
```

## 3. Changing the R Version

If you want to use a different version of R in RStudio, you must change it **outside** of RStudio before launching it.

3.1 Check which R versions are available on the system.

```bash
module avail r/
```

3.2 Load the desired R version together with RStudio. Replace `4.3.1` with the version you want.

```bash
module load r/4.3.1 rstudio
```

3.3 Launch RStudio using the selected R version.

```bash
rstudio
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ccv.brown.edu/stronghold/software/linux-standard-software/rstudio.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
