Home

Using Claude Code from WSL with RStudio on Windows

You have RStudio on Windows for running R code and Claude Code in WSL for AI-powered coding assistance. This tutorial shows you how to use both tools together on the same project files. You’ll create an R project in Windows, write some code manually, then use Claude Code from the Ubuntu terminal to enhance it with visualizations and analysis—all while RStudio stays open to run and test your code.

Key Concepts

What You’ll Need

Step 1: Open RStudio on Windows

Step 2: Create a New R Project

Step 3: Create a New R Script

Step 4: Write Initial Code Manually

Type this code into your iris.R file:

data(iris)
str(iris)
summary(iris)

Step 5: Open Ubuntu Terminal

Step 6: Navigate to Your Project Folder

Step 7: Launch Claude Code

Step 8: Ask Claude for a Scatter Plot

If Claude Code is slow or unresponsive, just wait for it to initialize. Then, type this request:

Add code to iris.R to create a scatter plot of sepal length vs. width, colored by species. Use ggplot2. 

Step 9: Run the New Code in RStudio

Step 10: Refine the Scatter Plot

Step 11: View the Refined Plot

Step 12: Ask Claude for PCA Plot

Step 13: Run the PCA Analysis

Step 14: Ask Claude to Review and Comment

Step 15: Ask Claude to Create R Markdown

Step 16: Knit the R Markdown File

Troubleshooting

Next Steps

Workflow Summary

This hybrid setup combines the best of both worlds:

The workflow is simple: write or edit code with Claude in the Ubuntu terminal, then immediately test and run it in RStudio. No file copying or manual syncing needed—WSL and Windows share the same files seamlessly.


Created by Steven Ge on December 11, 2025.