You can learn how to use R Markdown for Python from the following tutrials:
I. Create a Python environment in your project
Create a project using RStudio
Navigate into the RStudio project directory
Create a directory called “my_env”
Create a virtual environment in my_env
If you use pipenv and install Python 3.11, run the following command in the terminal:
pipenv –python 3.11 pipenv shell
You can install libraries using pip:
pipenv install pandas
install.packages(“reticulate”)
touch .Renviron echo ‘RETICULATE_PYTHON=RETICULATE_PYTHON = path/to/your/python’ > .Renviron
You can show the path for your Python by running the following command in the my_env directory:
pipenv –venv
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE
parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.