How to Use Python in R with Reticulate and Conda
Set up Reticulate in two simple steps and get the most out of R and Python libraries
We’ve all been there once or twice: you know the perfect Python function and you’re itching to use it, except you can’t. You’re stuck with R till the end of days. Or so you thought. No more! Perform this easy setup with Reticulate and Conda for your project and never make do without Python again.
This method is for you if you use the RStudio IDE (version 1.2 and up) and have Conda set up. Some basic familiarity with Terminal and the command line is required as well. Let’s get started.
Step 0: Set Up Your R Project
Go about your R business as usual. Set up your .RProject from the RStudio IDE by going to File > New Project. To demonstrate, let’s set up a new project in a project directory called my_project/. I usually have an R Markdown document to organise my analysis for each project so I create this as well: my_project.Rmd.
Now, install the Reticulate package from the console:
install.packages("reticulate")