-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.qmd
162 lines (105 loc) · 4.86 KB
/
index.qmd
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
# Welcome! {.unnumbered}
```{r}
#| eval: true
#| echo: false
#| include: false
source("_common.R")
```
<br><br>
:::: {layout="[70, 30]"}
::: {style='color: #000000;'}
[Develop your Shiny application as an R package.]{style='font-size: 1.25em; font-weight: bold; font-style: italic;'}
:::
![](images/sap_icon.png){class="cover" width="450" fig-align="right"}
::::
<br>
```{r}
#| label: co_box_dev
#| echo: false
#| results: asis
#| eval: true
co_box(
color = "r",
header = "Under Development",
size = "1.0",
hsize = "1.15",
look = "default",
fold = FALSE,
contents = "
This resource is currently being revised to include recent changes in the Shiny development landscape (Positron, AI tools, etc.). While most of the information in the 'Introduction' and 'App-packages' sections will remain unchanged, new sections are being written on:
1. Debugging
2. Testing
3. Deployment
4. Frameworks
Thank you for your patience!
"
)
```
```{r}
#| label: fig-shinyap_icon
#| echo: false
#| eval: false
#| out.width: NULL
#| fig-cap: |
#| An app-package is an R package that contains a shiny
#| application.
knitr::include_graphics("img/shinyap_icon.png", dpi = 270)
```
::: {layout="[10, 90]"}
![](images/00_index_shiny.png){fig-align="left" width="150"}
[Shiny](https://shiny.posit.co/) combines the power of R’s statistical capabilities with the interactivity of a web-based application.
:::
::: {layout="[85, 15]"}
[R packages](https://cran.r-project.org/web/packages/available_packages_by_name.html) are collections of pre-built, self-contained code, data, and documentation designed to perform operations or accomplish tasks beyond the capabilities of the R language.
![](images/R_logo.png){fig-align="right" width="180"}
:::
## What's in the book
```{r}
#| label: co_box_urls
#| echo: false
#| results: asis
#| eval: true
co_box(
color = "b",
header = "URLs",
size = "1.05",
hsize = "1.25",
look = "default",
fold = FALSE,
contents = "
- Short URL: **[https://bit.ly/ShinyAppPkgs](https://bit.ly/ShinyAppPkgs)**
- Full link: **[https://mjfrigaard.github.io/shiny-app-pkgs/](https://mjfrigaard.github.io/shiny-app-pkgs/)**
- GitHub repo: **[https://github.com/mjfrigaard/shiny-app-pkgs/](https://github.com/mjfrigaard/shiny-app-pkgs/)**
"
)
```
###
This book is a resource to help ‘connect the dots’ between building scalable Shiny applications and writing R packages. Adopting R package development practices in the early stages of your Shiny app will improve the reusability, maintainability, and shareability of all your hard work.
The code and data originate from the excellent [Building Web Applications with Shiny (BWAS)](https://rstudio-education.github.io/shiny-course/) course. If you're new to Shiny development this course is a great place to start. The four learning modules will provide a solid understanding for many of the topics covered in this book.
## What's not in the book
This book isn't a replacement for [Mastering Shiny](https://mastering-shiny.org/) or [R Packages, 2ed](https://r-pkgs.org/) (or [Writing R Extensions](https://cran.r-project.org/doc/manuals/R-exts.html)). I highly suggest bookmarking thse resources to return and read when you'd like to learn more about package development.
![](images/venn_diagram.png){width='100%' fig-align='center'}
I also won’t be recommending a particular Shiny framework or package, but I’ll cover a few popular choices, show what they're doing 'under the hood,' and let you decide if you'd like to adopt their practices.
## What I assume about you
If you’re reading this, I assume you’re comfortable with R, Posit Workbench, Shiny, and the `tidyverse`. Maybe you haven’t built a ton of applications, but you understand reactivity, and you’re comfortable with the core Shiny concepts (i.e., the UI, server, `*_Input()`, `*_Output()`, and `render_`* functions, etc.).
## Code examples
The code files for each chapter are stored in [GitHub repository](https://github.com/mjfrigaard/sap). Major code changes are stored in branches. Whenever a new branch is used, you'll see the **Git Branch** icon with a link to the repo/branch in the margin.
::::{.column-margin}
:::{style='font-size: 1.10em;'}
![](images/new_branch_ico.png){width='75%' fig-align='center'}
:::
:::{style='font-size: 1.05em;'}
See the [`<branch>`](https://github.com/mjfrigaard/sap/tree/02.1_shiny-app)
branch of [`sap`](https://github.com/mjfrigaard/sap).
:::
::::
In an effort to make the code and examples more accessible and easy to use, I've also created the [`shinypak` package](https://mjfrigaard.github.io/shinypak/):
**Example:**
<blockquote>
``` r
# install.packages('pak')
pak::pak('mjfrigaard/shinypak')
shinypak::launch('09.2_inst-bslib')
```
![](https://raw.githubusercontent.com/mjfrigaard/shinypak/main/man/figures/launch_app_pkg.gif){width="100%" fig-align="center"}
</blockquote>