Rstudio has been super dumb compared to other IDEs for its lack of AI-integrations, but integrating Claude Code into Rstudio terminal via Ubuntu can make a day-and-night different.
Literally took me 5 minutes to create a very complex plot that would originally take me an hour to create and tweak.
Step-by-step for installing Claude Code in Rstudio terminal (windows)
I don't have a Mac but the workflow should be fairly similar to this.
In your Command Prompt (open in Admin mode), install WSL by wsl --install. Then, restart your Command Prompt.
Windows + Q, search for Ubuntu and open it (this is your WSL terminal).
In your WSL terminal, run:
nvm install code
nvm use code
If you ran into the error of Command 'nvm' not found, try:
# Run the official installation script for 'nvm'
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Add 'nvm' to your session
export NVM_DIR="$HOME/.nvm"
source "$NVM_DIR/nvm.sh"
# Verify its installation
command -v nvm
# If successful, try install Node LTS again
nvm install node
nvm use code
# Check versions to make sure the installations were successful
node -v
npm -v
Once you had npm installed in your WSL, run:
npm install -g /claude-code
to install Claude Code. Once it's installed, you can close this window.
4. In the Global Settings/Terminal of Rstudio, select New terminals open with: Windows PowerShell.
5. At the bottom panel of Rstudio, create a new terminal in the Terminal section, and type in wsl -d Ubuntu to open WSL terminal. You have to open your WSL profile by this every time you created a new terminal in Rstudio!
6. Open your working directory and now you should be able to run Claude Code by trying in Claude in the RStudio terminal.
*For more information, check out Claude Code documentation: https://docs.anthropic.com/en/docs/claude-code/overview