forked from hadley/mastering-shiny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
introduction.Rmd
89 lines (54 loc) · 4.81 KB
/
introduction.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
# Introduction
```{r include = FALSE}
source("common.R")
```
## What is Shiny?
## What will you learn?
If you've never used Shiny before, welcome!
The first part of the book, "Getting started", is designed to get you up and running with Shiny as quickly as possible. This is pretty quick, because Shiny is carefully designed to let you get started writing apps as quickly as possible. We'll teach you a few recipes to follow that let you turn your existing R code into basic apps by wrapping key bits of code in `reactive({...})` or `renderXXX({...})`.
In "Shiny in Action", you'll learn a bunch of common patterns for building Shiny apps.
Then in "Mastering UI", you'll dive further into the many options you have for the front-end of your app.
In "Mastering reactivity", you'll go deep into the theory and practice of reactive programming, the programming paradigm that underlies Shiny. If you're an existing Shiny user, you'll get the most value out of this chapter as it will give you a solid theoretical underpinning that will allow you to create new tools specifically tailored for your problems.
The biggest drawback of reactive programming is that it's a fundamentally new programming paradigm. Even experienced R users can have trouble getting their heads around reactive programming, and those with deep experience in software engineering may feel uncomfortable with so much "magic". But once you've formed an accurate mental model, you'll see that there's nothing up Shiny's sleeves: the magic comes from simple concepts combined in consistent ways.
Finally, in "Taming Shiny" we'll finish up a survey of useful techniques for making your Shiny apps work well in production. You'll learn how to measure and improve performance, debug problems when they go wrong, and manage your app's dependencies.
## How to keep learning
## What won't you learn?
The focus of this book is making effective Shiny apps and understanding the underlying theory of reactivity. I'll do my best to show off best practices for data science, R programming, and software engineering at the same time as well, but you'll need other references to master these other important components.
## Prerequisites {#prerequisites}
The first thing you'll need to do is install the software you'll need, if you don't have it already:
### R {-}
If you don't have R installed already, you may be reading the wrong book; you need to be proficient with R if you want to write Shiny apps. If you'd like to learn how to use R, I'd recommend my [_R for Data Science_](https://r4ds.had.co.nz/) book which is designed to get you up and running with R with minimum of fuss.
### RStudio {-}
RStudio is a free and open source *integrated development environment* (IDE) for R: a single program that includes a code editor, R console, graphics device, and many features for working productively with R.
While you can write and use Shiny apps with any R environment (including R GUI and [ESS](http://ess.r-project.org)), RStudio has some nice features specifically for authoring, debugging, and deploying Shiny apps. We recommend giving it a try, but it's not required to be successful with Shiny or with this book.
You can download RStudio Desktop at <https://www.rstudio.com/products/rstudio/download>
### Shiny {-}
Shiny is an R package; you install it the same way you install any R package. From the R console:
```{r eval=FALSE}
install.packages("shiny")
```
### Other R packages {-}
This book is heavy on code, and we will often use other R packages in our examples. You can install them all now by running this code:
```{r eval=FALSE}
install.packages(c("magrittr", "lubridate", "readr", "dplyr", "ggplot2", "gt"))
```
TODO: Update this list before final draft; see [DESCRIPTION](https://github.com/hadley/mastering-shiny/blob/master/DESCRIPTION) for the definitive list.
## Cheat sheet
You may find it helpful to print a copy of our [Shiny "cheat sheet"](https://github.com/rstudio/cheatsheets/raw/master/shiny.pdf), a reference card for many of the most important concepts and functions in Shiny. It won't all make sense to you yet, but as you work through the chapters you'll find it more and more helpful to refresh your memory.
## Acknowledgements
This book was written in [bookdown](http://bookdown.org/) inside [RStudio](http://www.rstudio.com/ide/). The [website](http://mastering-shiny.org/) is hosted with [netlify](http://netlify.com/), and automatically updated after every commit by [travis-ci](https://travis-ci.org/). The complete source is available from [GitHub](https://github.com/hadley/mastering-shiny).
```{r, echo = FALSE}
ruler <- function(width = getOption("width")) {
x <- seq_len(width)
y <- dplyr::case_when(
x %% 10 == 0 ~ as.character((x %/% 10) %% 10),
x %% 5 == 0 ~ "+",
TRUE ~ "-"
)
cat(y, "\n", sep = "")
cat(x %% 10, "\n", sep = "")
}
```
```{r}
ruler()
```