NOTE: All instructions in capital letters indicate code that you should fill in with the appropriate information.

Set up your python

library(reticulate)
python:         /usr/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
version:        2.7.16 (default, Oct 17 2019, 17:14:30)  [GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s
numpy:          /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version:  1.8.0

python versions found: 
 /usr/bin/python
 /usr/bin/python3
 /usr/local/bin/python3
 /Users/buchanan/anaconda3/bin/python
ERROR: The requested version of Python
('/Users/buchanan/anaconda3/bin/python') cannot be used, as
another version of Python ('/usr/bin/python') has already
been initialized. Please restart the R session if you need
to attach reticulate to a different version of Python.
Error in use_python("/Users/buchanan/anaconda3/bin/python", required = TRUE) : 
  failed to initialize requested version of Python
py_config()
## python:         C:\Users\nanl\AppData\Local\CONTIN~1\ANACON~1\python.exe
## libpython:      C:/Users/nanl/AppData/Local/CONTIN~1/ANACON~1/python27.dll
## pythonhome:     C:\Users\nanl\AppData\Local\CONTIN~1\ANACON~1
## version:        2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 15:42:17) [MSC v.1500 64 bit (AMD64)]
## Architecture:   64bit
## numpy:          C:\Users\nanl\AppData\Local\CONTIN~1\ANACON~1\lib\site-packages\numpy
## numpy_version:  1.16.5
## 
## python versions found: 
##  C:\Users\nanl\AppData\Local\Continuum\anaconda2\envs\r-reticulate\python.exe
##  C:\PROGRA~1\Python37\python.exe
##  C:\Users\nanl\AppData\Local\CONTIN~1\ANACON~1\python.exe
##  C:\PROGRA~1\Python37\\python.exe
##  C:\Users\nanl\AppData\Local\Continuum\anaconda2\python.exe

Let’s do some R

data(rock)
head(rock,6)
##   area    peri     shape perm
## 1 4990 2791.90 0.0903296  6.3
## 2 7002 3892.60 0.1486220  6.3
## 3 7558 3930.66 0.1833120  6.3
## 4 7352 3869.32 0.1170630  6.3
## 5 7943 3948.54 0.1224170 17.1
## 6 7979 4010.15 0.1670450 17.1

Let’s do some Python

py_module_available('numpy')
## [1] TRUE
py_module_available('nltk')
## [1] TRUE
py_module_available('spacy')
## [1] FALSE
py_module_available('seaborn')
## [1] TRUE
py_module_available('pandas')
## [1] TRUE
#if they are all TRUE, leave this blank

Call a dataset in Python

import seaborn
var1 = seaborn.load_dataset("dots")
var1.head()
##   align choice  time  coherence  firing_rate
## 0  dots     T1   -80        0.0    33.189967
## 1  dots     T1   -80        3.2    31.691726
## 2  dots     T1   -80        6.4    34.279840
## 3  dots     T1   -80       12.8    32.631874
## 4  dots     T1   -80       25.6    35.060487

QUESTION: Look in your environment window. What do you see?

Get started with PyCharm!