Skip to content

Instantly share code, notes, and snippets.

@avallecam
Last active February 9, 2024 20:10
Show Gist options
  • Save avallecam/bb4ddaa385dedb9cea6bd39b8353a086 to your computer and use it in GitHub Desktop.
Save avallecam/bb4ddaa385dedb9cea6bd39b8353a086 to your computer and use it in GitHub Desktop.
quick start to use python within R
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
```
@avallecam
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment