-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
121,445 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Using R and Python Together with Reticulate | ||
|
||
R and Rstudio are great for workflows in statistics and data science, but what if you need to use a library that's only available in Python? What if your collaborators work in Python and you work primarily in R (or vice versa)? How might you share code and make it so your workflows come together? The `reticulate` package helps with these issues and can make bringing together R and Python a joy. | ||
|
||
Surely the folks at [RStudio](https://rstudio.github.io/reticulate/index.html) are the best source of information about this recent thrust in interoperability, however, after getting a feel for `reticulate` and how it might fit into my own workflow I'm happy to share a point of view about how to add this powerful tool to your own data science toolbox. |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
1,860 changes: 1,860 additions & 0 deletions
1,860
2020-01-28_reticulate/oc_rug_reticulate-rpubs.html
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# The only package you'll need installed ahead of time is pacman. | ||
# install.packages("pacman") | ||
|
||
# With the p_load() function, all packages specified are installed and loaded or just loaded if already available. | ||
pacman::p_load(reticulate, tidyverse, lubridate, ggthemes, janitor) | ||
|
||
# Let's specify the path the version of python you'd like to use inside the R session. | ||
use_python("/Users/michaelespero/opt/anaconda3/bin/python") | ||
|
||
# Now that the path to the desired version of python is specified, let's check that python is available in RStudio. | ||
# The initialize argument gets python started if it's not already. | ||
py_available(initialize = T) | ||
|
||
# With python available we can check to see if some of the python modules we want to use are ready. | ||
py_module_available(module = "numpy") | ||
|
||
py_module_available(module = "pandas") | ||
|
||
py_module_available(module = "sklearn") | ||
|
||
py_module_available(module = "nltk") | ||
|
||
# Lastly, we can check out the python configuration in RStudio with the py_config() function. | ||
py_config() | ||
|
||
# At this point R and Python may be ready to work together. | ||
# We'll go over things like installing Python modules and statistics/data science workflows in R and Python. | ||
|
||
|
||
|
||
|
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters