Last active
February 9, 2024 20:10
-
-
Save avallecam/bb4ddaa385dedb9cea6bd39b8353a086 to your computer and use it in GitHub Desktop.
quick start to use python within R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If I need to install python packages | |
```{python} | |
# install packages | |
pip install pandas | |
pip install matplotlib | |
``` | |
I can install python (!!) and the packages in R using `{reticulate}` | |
```{r} | |
# install python | |
reticulate::install_python() | |
# install packages | |
reticulate::py_install("pandas") | |
reticulate::py_install("matplotlib") | |
``` | |
Then, return to the python chunks | |
```{python} | |
# import packages | |
import pandas as pd | |
import matplotlib as plt | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for more info https://rstudio.github.io/reticulate/