I have Python installed and working in RStudio thanks to reticulate
.
For teaching, it would be very useful to create reprexes of Python code from inside the RStudio IDE but I cannot get it working. I've tried the reprexpy
package but cannot install it for some reason. I've also tried starting with reticulate::repl_python()
- long shot - and with py_run_file()
but that shows no output.
Here's an Rmd file showing some simple Python code that I'd like to reprex:
---
title: "Untitled"
author: "Robin Lovelace"
date: "06/02/2021"
output: html_document
---
```{r}
# Fails:
# reticulate::py_install("reprexpy")
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots() # Create a figure containing a single axes.
ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # Plot some data on the axes.