Skip to content
Discussion options

You must be logged in to vote

You need to use reticulate to pass values from Python to R,

---
title: "Untitled"
format: html
engine: knitr
---

```{r, setup}
library(reticulate)
```

Create a variable `x` in the Python session:

```{python}
x = [1, 2, 3]
```

Access the Python variable `x` in an R code chunk:

```{r}
py$x
```

or in `r py$x` the text.

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@sophia-hye
Comment options

@baptiste
Comment options

Answer selected by sophia-hye
@sophia-hye
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@cscheid
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants