-
Notifications
You must be signed in to change notification settings - Fork 2
/
RStudio_Ecosystem.Rmd
executable file
·314 lines (197 loc) · 20.4 KB
/
RStudio_Ecosystem.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
---
title: "The RStudio Ecosystem"
author: "by Stuart Hertzog"
date: "March–May 2018"
output:
html_document:
df_print: paged
pdf_document: default
word_document: default
---
![](images/RStudio_full_logo.png)
**The RStudio IDE is the flagship of a comprehensive RStudio ecosystem.**
## R Notebooks
[R Notebooks](https://rmarkdown.rstudio.com/r_notebooks.html) are the most basic type of [RMarkdown](#rmarkdown) document. They are the RStudio equivalent to [Jupyter Notebooks](https://jupyter.org/). As described by [RStudio](https://rmarkdown.rstudio.com/r_notebooks.html):
> An R Notebook is an R Markdown document with chunks that can be executed independently and interactively, with output visible immediately beneath the input.
**Any R Markdown document can be used as a Notebook, and all R Notebooks can be rendered to other R Markdown document types**.
### Creating An R Notebook
**The RStudio menu item _File -> New File -> R Notebook_** creates a new [RStudio Notebook](https://rmarkdown.rstudio.com/r_notebooks.html) containing instructions on how to use an R Notebook.
````
---
title: "R Notebook"
output:
html_notebook
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Cmd+Shift+Enter*.
```
{r}
plot(cars)
```
Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Cmd+Option+I*.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Cmd+Shift+K* to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
````
For more information see [RStudio Notebook](https://rmarkdown.rstudio.com/r_notebooks.html).
### R Notebook HTML files
**An [R Notebook HTML file](https://rmarkdown.rstudio.com/r_notebook_format.html) is a special type of [R Notebook](#r-notebook)**.
It is an HTML file that uses the `.nb.html` extension and it enables:
* **the source .Rmd document** and
* **chunk outputs** to be recovered.
The `html_notebook` output format is specified in the YAML metadata:
```
title: "my_document_title"
output:
html_notebook
```
With the `_yaml` file written this way, the command `rmarkdown::render()` will create an `.nb.html` R Notebook HTML Format file.
For more information, see [Details of the R Notebook HTML Format](https://rmarkdown.rstudio.com/r_notebook_format.html).
**Note**: The [RStudio instructions](https://rmarkdown.rstudio.com/r_notebook_format.html#generating-r-notebooks-with-custom-output) show an incorrect `YAML` header. You must use the `_yaml` format shown above or RStudio will throw an error and not compile.
## RMarkdown
> R Markdown documents are fully reproducible. They use a productive notebook interface to weave together narrative text and code to produce elegantly-formatted output from multiple languages including R, Python, and SQL.<br />--- [_RStudio RMarkdown_](https://rmarkdown.rstudio.com/)
**[RMarkdown documents](https://rmarkdown.rstudio.com/) are the default RStudio document**. They are plain-text files with the `.Rmd` extension and can be used to generate many different types of output. The main ones are:
* [HTML documents](https://rmarkdown.rstudio.com/html_document_format.html) -- `.html`
* [PDF Documents](https://rmarkdown.rstudio.com/pdf_document_format.html) -- `.pdf`
* [Word Documents](https://rmarkdown.rstudio.com/word_document_format.html) -- `.docx`
In addition to the standard output formats (above), RMarkdown documents can generate output in many other formats, via the [pandoc](#pandoc) conversion engine.
[Beamer](https://rmarkdown.rstudio.com/beamer_presentation_format.html), [HTML5 slides](https://rmarkdown.rstudio.com/ioslides_presentation_format.html), [Tufte-style handouts](https://rmarkdown.rstudio.com/tufte_handout_format.html), [books](https://bookdown.org/yihui/bookdown/), [dashboards](https://rmarkdown.rstudio.com/flexdashboard/), [interactive documents](https://rmarkdown.rstudio.com/authoring_shiny.html), [scientific articles](https://github.com/rstudio/rticles), and [websites](https://rmarkdown.rstudio.com/rmarkdown_websites.html).
[**RStudio maintains a gallery of examples**](https://rmarkdown.rstudio.com/gallery.html) of the many uses of RMarkdown.
### knitr
<image src="images/knitr.png" class="small-left-1em" />
> RMarkdown uses the [knitr](https://yihui.name/knitr/) report generation package to output to the different file formats.
**The `knitr` package enables integration of R code into [LaTeX](https://en.wikipedia.org/wiki/LaTeX), [LyX](https://en.wikipedia.org/wiki/LyX), [HTML](https://en.wikipedia.org/wiki/HTML), [Markdown](https://en.wikipedia.org/wiki/Markdown), [AsciiDoc](https://en.wikipedia.org/wiki/AsciiDoc), and [reStructuredText](https://en.wikipedia.org/wiki/ReStructuredText) documents**. It can execute code chunks in a variety of languages via [knitr Language Engines](https://rmarkdown.rstudio.com/authoring_knitr_engines.html), including for:
* R
* Python
* SQL
* Bash
* Rcpp
* Stan
* JavaScript
* CSS
**To process a code chunk using an alternate language engine** simply use the name of the engine in place of `{r}` in the chunk declaration, for example:
````
```{bash, eval = FALSE}
cat flights1.csv flights2.csv flights3.csv > flights.csv
```
````
#### Code Chunk Options
**RMarkdown code chunk processing can be controlled** by including [_Chunk Options_](https://rmarkdown.rstudio.com/lesson-3.html) in the _Chunk Declaration_, for example:
`{r, include = FALSE`} prevents code and results from appearing.
R Markdown still runs the code and the results can be used by other chunks.
`{r, eval = FALSE`} prevents to code from running but it still appears.
`{r, echo = FALSE`} prevents code but not the results from appearing.
This is a useful way to embed figures.
`{r, message = FALSE`} prevents messages generated by code from appearing.
`{r, warning = FALSE`} prevents warnings generated by code from appearing.
`{r, fig.cap = "..."`} adds a caption to graphical results.
The [R Markdown Reference Guide (.pdf)](https://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf) has a list of useful options. [Yihui's `knitr` options](https://yihui.name/knitr/options/) has full documentation of all `knitr` code processing controls.
### pandoc
The RStudio installation includes [pandoc](http://pandoc.org/), which is used for conversion between RMarkdown and [the various output formats](https://rmarkdown.rstudio.com/formats.html). You may have to [install pandoc on your system](http://pandoc.org/installing.html) for conversion to take place, especially for `.pdf` output, which goes through an intermediate `LaTeX` stage.
`pandoc` can also be run from the commond line if it is installed separately. This is explained in detail in the [pandoc manual](http://pandoc.org/MANUAL.html).
## Shiny
> [Shiny](http://shiny.rstudio.com/) is an R package that makes it easy to build interactive web apps straight from R. You can host standalone apps on a webpage or embed them in [R Markdown](http://rmarkdown.rstudio.com/) documents or build [dashboards](http://rstudio.github.io/shinydashboard/). You can also extend your Shiny apps with [CSS themes](http://rstudio.github.io/shinythemes/), [htmlwidgets](http://www.htmlwidgets.org/), and JavaScript [actions](https://github.com/daattali/shinyjs/blob/master/README.md).<br /> --- [_RStudio Shiny_](http://shiny.rstudio.com/)
**[RStudio's Shiny](http://shiny.rstudio.com/) is a Web application framework for R that takes static [RMarkdown documents](#rmarkdown) and [Web sites](https://rmarkdown.rstudio.com/html_document_format.html) to the next level**.
There is no limit to building online documentation, interactive tutorials, and statistical data interfaces with these powerful R packages:
* [`htmlwidgets`](http://www.htmlwidgets.org/) enables JavaScript visualisations and interactive components to be incorporated into [R Markdown documents](#rmarkdown) and Shiny web applications, as shown in this [showcase](http://www.htmlwidgets.org/showcase_leaflet.html) and this [gallery](http://www.htmlwidgets.org/)
* [`crosstalk`](http://rstudio.github.io/crosstalk/) wires widgets together, including linked brushing between widgets and client side filtering
* [`shinydashboard`](http://rstudio.github.io/shinydashboard/) makes it easy to create all kinds of Web dashboards, as shown in [these examples](http://rstudio.github.io/shinydashboard/examples.html)
and others:
* [`intrval`](https://github.com/psolymos/intrval) can be used to build for example, a [Web slider](http://peter.solymos.org/code/2018/03/08/shiny-slider-examples-with-the-intrval-r-package.html)
We will explore [building Shiny apps](http://shiny.rstudio.com/) in a future Tutorial.
### Shiny Server
[Shiny Server](https://www.rstudio.com/products/shiny/shiny-server/) makes your [Shiny Web apps](http://shiny.rstudio.com/) accessible on a local network, an Enterprise server, or on the Internet. There are two flavours of server:
* [Shiny Server Open Source](https://www.rstudio.com/products/shiny/download-server/) and
* [Shiny Server Pro](https://www.rstudio.com/products/rstudio-server-pro/)
Documentation is available for:
* [Installing Shiny Server Open Source](https://www.rstudio.com/products/shiny/download-server/)
* [Shiny Server Pro Admin Guide](http://docs.rstudio.com/shiny-server/)
* [shinyapps.io User Guide](http://docs.rstudio.com/shinyapps.io/index.html)
Shiny Apps can be available to an Intranet or to the Internet via:
* [An Enterprise Server](https://www.rstudio.com/products/rstudio-server-pro/)
* [RStudio Connect](https://www.rstudio.com/products/connect/)
* [shinyapps.io](https://www.rstudio.com/products/shinyapps/)
The difference between the latter two is [explained here](https://support.rstudio.com/hc/en-us/articles/217240558-What-is-the-difference-between-shinyapps-io-and-Shiny-Server-Pro-).
## bookdown
<img src="images/bookdown_logo.png" class="small-left" />
> [`bookdown`](https://github.com/rstudio/bookdown) is an open-source R package that makes it really easy to creates online books and technical documents using [RMarkdown](#rmarkdown).
**`bookdown` books open a new avenue for Web-enabled book publishing**.
They are essentially **responsive RMarkdown Web sites**, complete with content navigation, plus the ability to display and process computer code using a wide range of programming languages, including interactive [Shiny dashboards](http://rstudio.github.io/shinydashboard/examples.html) and [Web apps](http://shiny.rstudio.com/gallery/).
**`bookdown` has added a few important missing features** related to writing books, such as figure and table caption numbering and cross-references, and the ability to embed [HTML widgets](https://www.rstudio.com/products/shinyapps/) or [Shiny apps](http://shiny.rstudio.com/gallery/).
**Developed and maintained by RStudio software engineer [Yihui Xie](http://yihui.name)**, `bookdown` books can be published on [bookdown.org](https://bookdown.org/), a free service provided by [RStudio Inc](https://www.rstudio.com/about/). Books are available for download, and the author holds full copyright.
[<img src="https://bookdown.org/yihui/bookdown/images/cover.jpg" class="small-left" />](https://bookdown.org/)
**Fully-documented** in --- of course! --- a [`bookdown` book called _bookdown_](https://bookdown.org/yihui/bookdown/), the `bookdown` package uses many of the same conventions as [other RMarkdown document types](#rmarkdown), so conversion of any RStudio project to an online book is relatively straightforward.
[A Minimal Book Example](https://github.com/rstudio/bookdown-demo) can be cloned from GitHub. It can also be downloaded as a [`.zip` file](https://github.com/rstudio/bookdown-demo/archive/master.zip) if you are [not familiar with GitHub](http://rogerdudler.github.io/git-guide/).
### `bookdown` Installation
[Installation](https://bookdown.org/home/getting-started.html) requires the [devtools](https://www.rstudio.com/products/rpackages/devtools/) R package to be first installed, after which `bookdown` can be installed from [its GitHub repository](https://github.com/rstudio/bookdown):
```{r eval = FALSE}
install.packages("devtools")
devtools::install_github("rstudio/bookdown")
```
### `tinytex`
**PDF output requires some version of the [LaTeX](https://www.latex-project.org/) typesetting system** to be installed. LaTeX is not a stand-alone typesetting program in itself, but document preparation software that runs on top of Donald E. Knuth's [TeX typesetting system](https://en.wikipedia.org/wiki/TeX).
**[TeX distributions](https://www.latex-project.org/get/#tex-distributions) usually bundle together all the parts needed** for a working TeX system. [LaTeX](https://www.latex-project.org/) and many of the packages built on it form an important component of any modern TeX distribution.
**As this is a large package consisting of many gigabytes of files** that users may not wish to install, [Yihui Xie wrote `tinytex`](https://yihui.name/tinytex/), a lightweight, cross-platform, portable, and easy-to-maintain LaTeX distribution based on [TeX Live](https://en.wikipedia.org/wiki/TeX_Live).
#### `tinytex` Installation
Installation of `tinytex` is accomplished with:
```{r, eval = FALSE}
install.packages(c('tinytex', 'rmarkdown'))
tinytex::install_tinytex()
```
<span class="glyphicon glyphicon-hand-right"></span> **[PDF output](https://rmarkdown.rstudio.com/pdf_document_format.html) (including [Beamer slides](https://rmarkdown.rstudio.com/beamer_presentation_format.html)) requires a full TeX installation.**
## blogdown
<img src="images/blogdown.png" class="small-left-1em" />
> Just as [WordPress](https://wordpress.com/) changed the Web by bringing blogging to the masses, [blogdown](https://bookdown.org/yihui/blogdown/) has opened a path for the more computer-savvy to create quick-loading, static blog sites using [RMarkdown](#rmarkdown).
Not content with authoring [`bookdown`](#bookdown), RStudio developer [Yihui Xie](http://yihui.name) took the next logical step by writing the [`blogdown` R package](https://bookdown.org/yihui/blogdown/).
**Based on the [Hugo website framework](https://gohugo.io/), `blogdown` lets you write posts in RStudio as RMarkdown.Rmd files These are automatically converted to blog posts for uploading to a hosting service, including [GitHub pages](https://pages.github.com/)**.
### Learning `blogdown`
It is advisable to first read Yihui Xie and Alison Presmanes Hill's `bookdown` book [Creating Websites with R Markdown](https://bookdown.org/yihui/blogdown/) to become familiar with `bookdown` concepts and the [Hugo framework](https://gohugo.io/) before you embark on creating your first blog site.
**These links offer practical Setup hints and guidance:**
#### blogdown Setup
* [Up and running with blogdown | Alison Presmanes Hill](https://alison.rbind.io/post/up-and-running-with-blogdown/)
* [Getting Started With Blogdown | Borasky Research Journal](https://www.znmeb.mobi/2017/05/12/getting-started-with-blogdown/)
* [R Blogdown Setup in GitHub (2) | Tales of R](https://aurora-mareviv.github.io/talesofr/2018/02/r-blogdown-setup-in-github-2/)
* [A Technical Introduction to Yihui's personal website ](https://support.rbind.io/2017/04/25/yihui-website/#fnref:For-two-reasons)
* [A not-so-technical introduction to Daijiang's personal website](https://support.rbind.io/2017/04/28/daijiang-website/#fnref:frankly-I-cloned)
#### blogdown Links
* [blogdown: Creating Websites with R Markdown](https://bookdown.org/yihui/blogdown/)
* [Announcing blogdown - Yihui Xie, RStudio 2017-09-11](https://blog.rstudio.com/2017/09/11/announcing-blogdown/)
* [GitHub - rstudio/blogdown: Create Blogs and Websites with R Markdown](https://github.com/rstudio/blogdown)
* [GitHub - rbind/blogdown-demo: A minimal website example using blogdown](https://github.com/rbind/blogdown-demo)
* [Twitter hashtag #blogdown](https://twitter.com/hashtag/blogdown)
### Hugo Themes
**`blogdown` uses [Hugo themes](https://gohugo.io/themes/) to style the look and feel of its blogs**. The default theme for `blogdown` is [_hugo-lithium_](https://github.com/yihui/hugo-lithium), a minimal theme that offers several options, detailed in [Section 2.4.1](https://bookdown.org/yihui/blogdown/themes.html#the-default-theme) of the `blogdown` book. The base theme can be modified to suit your taste, or it can be replaced by another theme.
**The [Hugo web site](https://gohugo.io/) showcases many [user-contributed themes](https://themes.gohugo.io)**. These can be examined online and downloaded for use as-is or as a starting point for themeing.
#### Hugo Links
* [Hugo](https://gohugo.io/) --- world's fastest (?) framework for building websites
* [Hugo Setup Guide](https://gohugo.io/getting-started/installing/) --- applies to `blogdown` blog sites
* [Hugo Themeing](https://gohugo.io/themes/) --- how to choose and fine-tune a blog
* [Contributed Hugo Themes](https://themes.gohugo.io) -- hundreds of excellent Hugo themes
* [Converting Old Wordpress Posts To Hugo](https://riinu.netlify.com/2018/02/converting-old-wordpress-posts-to-hugo/) --- goodbye WordPress!
### `blogdown` Blogs
A list of R-related `blogdown` blogs is kept at [rbind on Github](https://github.com/rbind). R-blogs made with `blogdown` can be viewed [here](https://github.com/search?q=org%3Arbind+blogdown).
An interesting and uncluttered example is [Simply Statistics](https://simplystatistics.org/), a statistics blog by Rafa Irizarry, Roger Peng, and Jeff Leek.
## RStudio Products
![](images/RStudio_full_logo.png)
**Some RStudio products are open-source and free for student and personal use**. Others are priced for professional or Enterprise deployment.
### Software
* [R Notebooks](https://rmarkdown.rstudio.com/r_notebooks.html) --- equivalent to [Jupyter Notebooks](https://jupyter.org/)
* [RMarkdown](https://rmarkdown.rstudio.com/) --- creates `.Rmd` files using [Pandoc Markdown](https://rmarkdown.rstudio.com/authoring_pandoc_markdown.html)
* [R Packages](https://www.rstudio.com/products/rpackages/) --- available on [CRAN](https://cran.r-project.org/) and [GitHub](https://github.com/rstudio)
* [RStudio Desktop](https://www.rstudio.com/products/rstudio/#Desktop) --- the RStudio IDE, also on [GitHub](https://github.com/rstudio)
* [RStudio Server](https://www.rstudio.com/products/rstudio/#Server) --- free for personal and local Network use
* [Shiny](https://www.rstudio.com/products/shiny/) --- build interactive Web pages and [JavaScript](https://www.javascript.com) apps
* [Shiny Server](https://www.rstudio.com/products/shiny/shiny-server2/) --- free for local network and Web access behind a firewall
### Cloud Services
* [RStudio Server Pro](https://www.rstudio.com/products/rstudio-server-pro/) -- enhanced admin, Enterprise security and pricing
* [RStudio Connect](https://www.rstudio.com/products/connect/) -- team management, Enterprise security and pricing
* [RStudio Cloud (in alpha)](https://rstudio.cloud/) --- Do, Share, Teach, and Learn Data Science
* [Shiny Server Pro](https://www.rstudio.com/products/shiny-server-pro/) -- share Shiny apps, Enterprise security and pricing
* [shinyapps.io](https://www.rstudio.com/products/shinyapps/) -- deploy Shiny apps, enhanced security, scalable
* [Bookdown Book Publishing](https://bookdown.org/) --- free for `bookdown` static page books
### Resources
* [RStudio Cheat Sheets](https://www.rstudio.com/resources/cheatsheets/) --- PDF format
* [RStudio Community](https://community.rstudio.com/) --- register for full Forum access
* [RStudio Documentation](https://support.rstudio.com/hc/en-us/categories/200035113-Documentation) --- Help articles for all RStudio products
* [RStudio Server> Getting Started](https://support.rstudio.com/hc/en-us/articles/234653607-Getting-Started-with-RStudio-Server) --- lists many links for setup and use
* [RStudio Server Pro Admin. Guide](http://docs.rstudio.com/ide/server-pro/) --- web-accessible User Manual
<p class="bottom-navbar"><span class="bottom-navbar-contents"><span class="glyphicon glyphicon-arrow-left"> </span> [<span class="bottom-navbar-link">Part 1 - RStudio IDE</span>](RStudio.html) | [<span class="bottom-navbar-link">Part 2 - Fundamentals of R</span>](R_Programming.html) <span class="glyphicon glyphicon-arrow-right"></span></span></p>