Wait, what?? Why would you use R Studio as an IDE for running Python? There’s a simple answer to this question: this is the perfect Data Science IDE when you use R and Python together.
You’ll find below the simple steps to help set up a project in R Studio so you can start using Python:
Create an R Studio Project:
Navigate and save your project: File -> New Project – > Existing Directory (linked to the GitHub folder if applicable) / New Directory ( if you work locally) .
Create and activate Python virtual environment
Each project might require different versions of packages and this can be encapsulated in a virtual environment. You’ll have to create and select the virtual environment as the Python interpreter for the RStudio Project and then activate.
- Install virtual environment with pip install in the RStudio terminal window (initial setup):
pip install virtualenv
- Create the virtual environment for the current project (initial setup):
- Activate the virtual environment for the current project (initial setup):
- on Windows:
- on MAC:
Select Python interpreter
Navigate and select your Python interpreter : Tools -> Global Options – > Python -> Select -> Virtual environments
When you open the project, just remember to activate the environment:
(Note: I participate in the affiliate amazon program. This post may contain affiliate links from Amazon or other publishers I trust (at no extra cost to you). I may receive a small commission when you buy using my links, this helps to keep the blog alive! See disclosure for details.)
If you’re new to RStudio , you can browse this book.
Once you start coding, you might be also interested in reading:
- the 17 Clean Code standards to adopt NOW!
- “Freeze” your Python environment by creating the Requirements.txt file
This is a personal blog. My opinion on what I share with you is that “All models are wrong, but some are useful”. Improve the accuracy of any model I present and make it useful!