RStudio v1.2 brings support for the reticulate package, including:
1) Support for executing reticulated Python chunks within R Notebooks.
2) Line-by-line execution of Python code using the reticulate repl_python()
function.
3) Sourcing Python scripts using the reticulate source_python()
function.
4) Code completion and inline help for Python.
5) Display of matplotlib plots within both notebook and console execution modes.
A note about the philosophy behind Python tools within RStudio: these tools are not intended for standalone Python work but rather explicitly aimed at the integration of Python into R projects (and as such are closely tied to the reticulate package).
There are many IDEs available for doing data science with Python including JupyterLab, Rodeo, Spyder, and Visual Studio Code, and we strongly recommend using one of them for Python-only projects. However, if you are using reticulated Python within an R project then RStudio provides a set of tools that we think you will find extremely helpful.
You can download the latest RStudio release here: https://rstudio.com/products/rstudio/download/.
All of the features described below require that you have previously installed the reticulate package, which you can do as follows:
install.packages("reticulate")
R Notebooks have been enhanced to support executing Python chunks using the reticulate Python engine. For example:
{.screenshot width="98%"}
R Notebooks can also display matplotlib plots inline when they are printed from Python chunks:
{.screenshot width="98%"}
You can execute code from Python scripts line-by-line using the Run button (or Control+Enter) in the same way as you execute R code line-by-line. RStudio will automatically switch into reticulate's repl_python()
mode whenever you execute lines from a Python script:
{.screenshot width="98%"}
Type exit
from the Python REPL to exit back into R (RStudio will also automatically switch back to R mode whenever you execute code from an R script).
Click the editor's Source Script button within a Python source file to execute a script using reticulate's source_python()
function:
{.screenshot width="98%"}
RStudio now provides code completion for Python scripts:
{.screenshot width="98%"}
Additionally, pressing the F1 button over a Python symbol will display the help topic for that symbol:
{.screenshot width="98%"}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.