-
Notifications
You must be signed in to change notification settings - Fork 32
/
10-other_niceties.Rmd
39 lines (28 loc) · 1.76 KB
/
10-other_niceties.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Further topics
This chapter is a collection of short section that show some of the very nice things you can use
R for. These sections are based on past blog posts.
## Using Python from R with `{reticulate}`
There is a lot of discussion online about the benefits of Python over and vice-versa. When it comes
to data science, they are for the most part interchangeable. I would say that R has an advantage
over Python when it comes to offering specialized packages for certain topics such as
econometrics, bioinformatics, actuarial sciences, etc... while Python seems to offer more possibilities
when it comes to integrating a machine learning model into an app.
However, if most of your work is data analysis/machine learning, both languages are practically
interchangeable. But it can happen that you need access to a very specific library with no R
equivalent. Well, in that case, no need to completely switch to Python, as you can call Python code
from R using the `{reticulate}` package.
`{reticulate}` allows you to seamlessly call Python functions from an R session. An easy way to use
`{reticulate}` is to start a a new notebook, but you can also use `{reticulate}` and the included
functions interactively. However, I find that Rstudio notebooks work very well for this particular
use-case, because you can write R and Python chunks, and thus differentiate the different
specific lines of code really well.
Let's see how this works. First of all, you might need to specify the path to your Python executable,
in my case, because I've installed Python using Anaconda, I need to specify it:
```
# This is an R chunk
use_python("~/miniconda3/bin/python")
```
## Generating Pdf or Word reports with R
## Scraping the internet
## Regular expressions
## Setting up a blog with `{blogdown}`