Chapter 2 Installation
Before we can do anything, we need to install the package. The package is currently located on my github page. If you have it installed devtools
, please run install.packages(“devtools”).
devtools::install_github('fdrennan/biggr')
## Downloading GitHub repo fdrennan/biggr@master
##
##
checking for file ‘/private/var/folders/1q/j1clv3hj53174q0d05p52fsw0000gn/T/RtmpcYNGzb/remotes21c3182b26d/fdrennan-biggr-4f34d44/DESCRIPTION’ ...
✔ checking for file ‘/private/var/folders/1q/j1clv3hj53174q0d05p52fsw0000gn/T/RtmpcYNGzb/remotes21c3182b26d/fdrennan-biggr-4f34d44/DESCRIPTION’
##
─ preparing ‘biggr’:
##
checking DESCRIPTION meta-information ...
✔ checking DESCRIPTION meta-information
##
─ checking for LF line-endings in source and make files and shell scripts
##
─ checking for empty or unneeded directories
##
─ building ‘biggr_1.2.0.tar.gz’
##
##
Once this is complete, we will use two packages. biggr
and reticulate
. For more on reticulate, visit Rstudio.
library(biggr)
library(reticulate)
Next use the install_python
and choose an environment name to install the package. By default, R uses the virtual environment r_reticulate
. You can use this environment or specify a different name. I will use a different name below. My understanding is that if you do not specify the environment, each time you load up R you will not have to specify which environment to use because R uses r_reticulate
by default. *You can also use Conda by specifying method = conda
. The insides of the function are directly below.
install_python
## function (method = "auto", conda = "auto", envname = "r_reticulate")
## {
## reticulate::py_install("scipy", method = method, conda = conda,
## envname = envname)
## reticulate::py_install("awscli", method = method, conda = conda,
## envname = envname)
## reticulate::py_install("boto3", method = method, conda = conda,
## envname = envname)
## }
## <bytecode: 0x7fce2c638150>
## <environment: namespace:biggr>
Here we create a virtual environment named biggr
.
install_python(envname = 'biggr')
Next we go ahead and set which environment we want to use.
use_virtualenv('biggr')
Here we verify that we are in fact using the correct environment.
py_config()
## python: /Users/digitalfirstmedia/.virtualenvs/biggr/bin/python
## libpython: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
## pythonhome: /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
## virtualenv: /Users/digitalfirstmedia/.virtualenvs/biggr/bin/activate_this.py
## version: 2.7.10 (default, Aug 17 2018, 19:45:58) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)]
## numpy: /Users/digitalfirstmedia/.virtualenvs/biggr/lib/python2.7/site-packages/numpy
## numpy_version: 1.16.3
## scipy: /Users/digitalfirstmedia/.virtualenvs/biggr/lib/python2.7/site-packages/scipy
##
## python versions found:
## /Users/digitalfirstmedia/.virtualenvs/biggr/bin/python
## /Users/digitalfirstmedia/.virtualenvs/r-reticulate/bin/python
## /usr/bin/python
## /usr/local/bin/python
## /usr/local/bin/python3
## /Users/digitalfirstmedia/.virtualenvs/biggr_env/bin/python
## /Users/digitalfirstmedia/.virtualenvs/py3-virtualenv/bin/python
## /Users/digitalfirstmedia/.virtualenvs/r_reticulate/bin/python
## /Users/digitalfirstmedia/.virtualenvs/r-tensorflow/bin/python
## /Users/digitalfirstmedia/.virtualenvs/venv/bin/python
## /Users/digitalfirstmedia/.virtualenvs/voicecode/bin/python
## /anaconda3/envs/r-tensorflow/bin/python
## /Users/digitalfirstmedia/.talon/bin/python
2.1 Authentication with AWS
Next we set permissions. You need to go to the AWS console and create a user which has administrator access. This will set the environment variables for the underlying aws command line interface.
configure_aws(aws_access_key_id = "XXXXXXXXXX",
aws_secret_access_key = "XXXXXXXXXX",
default.region = "us-east-2")
Then finally we verify that the package is in fact working in talking to Python as well as AWS.
s3_list_buckets()
## # A tibble: 4 x 2
## name creation_date
## <chr> <chr>
## 1 couch-dog-photos 2019-03-08 04:45:05+00:00
## 2 fdrennanunittest 2019-05-02 21:15:04+00:00
## 3 freddydbucket 2019-05-03 05:46:19+00:00
## 4 kerasmods 2019-01-29 20:47:11+00:00