knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
PressPurt depends on R >= 3.1.0. To check your R version run version
from the R console.
This package also depends on the following R libraries:
data.table
ggplot2
gridExtra
reticulate >= 1.11
If not already installed, these packages will be installed upon the installation of PressPurt
.
This package is dependent on python and uses the R package reticulate
under the hood to use python. Thus python and the dependent packages must be installed.
There are two suggested approaches:
It is also possible to set a specific version of python with reticulate::use_python("/path/to/python")
before you run any of the PressPurt
commands but it is not recommended. You'll also have to ensure that the dependent python packages are installed. For more information on using reticulate
directly: see the reticulate docs.
If needed, install virtualenv
with pip
.
```{bash, eval=FALSE}
pip install virtualenv
virtualenv --version
virtualenv venv
#### Installing python dependencies ##### From R The `create_virtual_env` function lets one create a virtual environment to use. If you want to make a new virtual environment, you'll need to specify which python version to use in addition to the virtual environment name. You may check which version(s) of python you have in a fresh R session with `find_python()`. You should use the sample one you used to install `virtualenv`. ```r create_virtual_env(version = "/usr/bin/python3", virtualenv = "PressPurtEnv", verbose = TRUE)
Next you'll need to install the python dependencies in your virtual environment. This will install the following into your PressPurtEnv
virtual env:
numpy
scipy
matplotlib
sympy
pathos
pandas
py_depend(virtualenv = "PressPurtEnv")
If you want to use the PressPurtEnv
environment in a new R session you can access it via:
set_python_virtual(virtualenv = "PressPurtEnv")
Now that you have created the virtual environment and installed dependencies, you can use the new env in R! Run:
# load the library library(PressPurt) # You should see "PressPurtEnv" listed as a conda env find_python() # Set your virtualenv set_python_virtual(virtualenv = "PressPurtEnv")
Conda is a package and environment manager that is open source. The main difference between Anaconda and Miniconda is that Anaconda comes with a bundle of pre-installed packages so it takes longer to download and install. Both Miniconda and Anaconda come with python but you can specify a specific version of python later as well.
This document will show you how to install Miniconda via the command-line. For more information on installation and how to install it graphically (no command-line) see the conda docs
bash Miniconda3-latest-Linux-x86_64.sh
conda list
bash Miniconda3-latest-MacOSX-x86_64.sh
conda list
.exe
file by double clicking.conda list
First you'll need to load PressPurt
, check which versions of python are found and if any Conda environments exists.
# load the library library(PressPurt) # Find the versions of python, conda environments and virtualenvs available on your machine: find_python()
This shows you your default Python path, other available python paths, a list of your conda environments and virtual environments.
The create_conda_env
function lets one create a new conda environment -- you'll most likely need to specify which python version to use in addition to the conda environment name. This function also sets your conda environment to the newly created one.
You may have python installed under /usr/bin/python3
, Anaconda2 and/or Anaconda3, so you may need to specify which python to use.
create_conda_env`(condaenv="PressPurtEnv", version="~/anaconda3/bin/python", verbose = TRUE)
Next you'll need to install some additional python dependencies that PressPurt needs into your conda environment. This will install the following into your PressPurtEnv
conda env:
numpy
scipy
matplotlib
sympy
pathos
pandas
py_depend(condaenv = "PressPurtEnv")
If the dependencies don't install correctly see below for instructions on how to install via the command-line.
If you want to use the PressPurtEnv
environment in a new R session you can access it via:
set_python_conda(condaenv="PressPurtEnv")
You can also install your Python dependencies via the command line with conda or with the Anaconda Prompt (Windows).
When you activate conda it starts the "base" environment. You'll want to create a specific environment to install all of the PressPurt requirements.
```{bash, eval=FALSE}
conda --version
conda info --envs
conda create --name PressPurtEnv
source activate PressPurtEnv
conda list
conda install matplotlib numpy pandas scipy sympy pip install pathos
conda list
Now that you have created the conda environments and installed dependencies, you can use the new environment in R. Run: ```r # load the library library(PressPurt) # You should see "PressPurtEnv" listed as a conda env find_python() # Set your conda env set_python_conda(condaenv="PressPurtEnv")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.