

# Using the RStudio IDE in Amazon SageMaker Unified Studio

RStudio is an integrated development environment for R, provided through Posit Workbench. In Amazon SageMaker Unified Studio, you can create an RStudio space to write, run, and visualize R code with access to the data and resources in your project. RStudio spaces behave like other code spaces: each space maintains its own persistent Amazon EBS volume, compute instance, and runtime configuration. For more information about RStudio concepts, components, and Region availability, see [RStudio on Amazon SageMaker AI](https://docs.aws.amazon.com/sagemaker/latest/dg/rstudio.html) in the *Amazon SageMaker AI Developer Guide*.

## Prerequisites
<a name="rstudio-prerequisites"></a>

Before you can use RStudio, your administrator or project owner must set up the following:
+ A valid RStudio (Posit Workbench) license registered and accepted with AWS License Manager for the account that hosts your domain. For how to obtain and validate a license, see [Get an RStudio license](https://docs.aws.amazon.com/sagemaker/latest/dg/rstudio-license.html) in the *Amazon SageMaker AI Developer Guide*.
+ An Amazon SageMaker domain that uses IAM Identity Center and the SageMakerAIDomain blueprint, with RStudio enabled (the `enableRStudio` parameter). The Tooling blueprint does not offer RStudio. For how to set this up, see [Setting up the SageMakerAIDomain blueprint for code spaces](https://docs.aws.amazon.com/sagemaker-unified-studio/latest/adminguide/sagemaker-ai-domain.html).
+ The required inline policy attached to your project's IAM role. This policy grants the permissions that RStudio and Posit Workbench require for license checkout, log delivery, and application lifecycle operations. Without it, RStudio space creation or session startup fails. For how to add this policy, see [Adding the required inline policy for RStudio](https://docs.aws.amazon.com/sagemaker-unified-studio/latest/adminguide/sagemaker-ai-domain.html#sagemaker-ai-domain-rstudio-policy).

## Creating and launching an RStudio space
<a name="rstudio-create-space"></a>

After the prerequisites are in place, you can create an RStudio space and start a session. To create and launch a space, complete the following steps:

1. Navigate to Amazon SageMaker Unified Studio using the URL from your admin and log in using your SSO or AWS credentials. 

1. Navigate to the project you want to create a space in, and then choose **Code spaces** from the left sidebar.

1. Choose **Create space**, and then choose the **RStudio** application type.

1. Choose **Create** to create and start the space.

1. When the space is ready, choose **Open** to launch RStudio in your browser.

1. In Posit Workbench, choose **New Session** and wait until the session starts. You can then run R code in the session.