To get this tutorial started, we need, first, to install anaconda, and second, activate an r-reticulate environment using conda. We also need to install vega_datasets using pip and finally, install the R packages reticulate and altair using install.packages() in Rstudio. Most of the steps described here are taken from altair R installation. Make sure you are using Python version 3.5 or higher to comply to the system requirements of the altair R package altair CRAN.
First, install Anaconda and after installing Anaconda, open the Anaconda Prompt. Update conda:
conda -V
conda update conda
Install the vega datasets that we will be used in this tutorial:
pip install vega_datasets
Next, create and activate a conda environmnet called r-reticulate
:
conda create -n r-reticulate
conda activate r-reticulate
Open Rstudio IDE and install reticulate. Then, use the conda environment r-reticulate
:
install.packages("reticulate")
reticulate::use_condaenv("r-reticulate")
Restart Rstudio and then install the altair package:
install.packages("altair")
In Rstudio, use the code below to install the Python packages altair and vega_datasets:
altair::install_altair()
Verify the installation using:
altair::check_altair()
If there is no error on the verification, we are ready to start!
The procedure described above should be run only in the beginning. The following times you want to use altair in Rstudio, you only need to call library("altair")
.