|
1 | | -## Developing a reproducible Shiny app |
| 1 | +# Developing a reproducible Shiny app |
2 | 2 |
|
3 | | -Example Shiny application adopting the recommendations of "10 Quick Tips for Developing a Reproducible Shiny Application", Brun et al, 2025, PLOS Computational Biology. |
| 3 | +Example Shiny application adopting the recommendations of "Ten Quick Tips for Developing a Reproducible Shiny Application", Brun et al, 2025, PLOS Computational Biology. |
4 | 4 |
|
5 | 5 | In this example, we are reusing the Faithful Shiny app example (<https://shiny.posit.co/r/gallery/start-simple/faithful/>) provided as part of the R `shiny` package. This Shiny application displays eruption data for the Old Faithful geyser. |
6 | 6 |
|
7 | | -Tips demonstrated: |
| 7 | +## Tips demonstrated: |
8 | 8 |
|
9 | 9 | - Set up your computing environment |
10 | 10 | - Use git and GitHub |
11 | 11 | - Use `renv` to record package versions |
12 | 12 | - Record the output of `sessionInfo()` |
13 | 13 | - Document and develop incrementally |
14 | 14 | - Comment UI elements |
15 | | -- Make your Shiny application portable and easy to maintain |
| 15 | +- Make your Shiny application modualr and portable |
16 | 16 | - Organize code and data |
17 | 17 | - Use relative paths and `file.path` |
18 | 18 | - Preprocess and cache data for performance |
19 | | - - Cache processed data in a local file |
| 19 | + - Cache remotely-accessed and processed data in a local file |
20 | 20 | - Make underlying data accessible |
21 | 21 | - Cite the original data |
22 | 22 | - License code and data appropriately |
23 | 23 | - Add a LICENSE file |
24 | 24 | - Respect the license of the original data |
25 | | -- Make you data and source code citable |
26 | | - - Add README and CITATION.cff files |
27 | | -- Publish your app |
| 25 | +- Make your data and source code citable |
| 26 | + - Add a suggested citation to the README |
| 27 | + - Add a CITATION.cff file |
| 28 | +- Share your app |
28 | 29 | - Publish on shinyapps.io and archive in Zenodo |
| 30 | + |
| 31 | +## How to run this Shiny app |
29 | 32 |
|
30 | | -The underlying data is available as part of R package X. The original source is... |
| 33 | +1. Clone this repository and run at the R console: `shiny::runApp()` |
| 34 | +2. At the R console run: `shiny::runGitHub(repo="shiny-qt-example", "UCSB-Library-Research-Data-Services")` |
31 | 35 |
|
32 | | -Cite this work as: Brun, J., Janée, G., & Curty, R. G. (2025). Example Shiny application adopting the recommendations from "10 Quick Tips for Developing a Reproducible Shiny Application" [Computer software]. <https://github.com/UCSB-Library-Research-Data-Services/shiny-qt-examples> |
| 36 | +## File structure |
| 37 | + |
| 38 | +This repository has the following file structure: |
| 39 | + |
| 40 | +```bash |
| 41 | +├── CITATION.cff |
| 42 | +├── data |
| 43 | +│ ├── faithful_data.csv |
| 44 | +│ └── metadata.md |
| 45 | +├── global.R |
| 46 | +├── LICENSE |
| 47 | +├── README.md |
| 48 | +├── renv |
| 49 | +│ ├── activate.R |
| 50 | +│ ├── library |
| 51 | +│ ├── settings.json |
| 52 | +│ └── staging |
| 53 | +├── renv.lock |
| 54 | +├── server.R |
| 55 | +├── sessionInfo.txt |
| 56 | +├── shiny-qt-example.Rproj |
| 57 | +└── ui.R |
| 58 | +``` |
| 59 | + |
| 60 | +### Shiny app |
| 61 | + |
| 62 | +- `global.R`: Load libraries and check for existing data files |
| 63 | +- `server.R`: server side functions of the Shiny app used to compute the histogram plot and other plot features |
| 64 | +- `ui.R`: user interface of the Shiny app |
| 65 | + |
| 66 | +### Virtual computing environment |
| 67 | + |
| 68 | +This app uses `renv` to create a virtual environment |
| 69 | + |
| 70 | +- `renv.lock`: list of the R packages used by the virtual environment |
| 71 | +- `.Rprofile`: ensures that the library is used every time you open that project |
| 72 | +- `renv/activate.R`: R script sourced by .Rprofile to activate the virtual environment |
| 73 | +- `renv/settings.json`: virtual environment settings |
| 74 | + |
| 75 | +### Data |
| 76 | + |
| 77 | +- `faithful_data.csv`: CSV file version of the faithful data from the datasets R package |
| 78 | +- `metadata.md`: metadata information about faithful_data.csv |
| 79 | + |
| 80 | +## References |
| 81 | + |
| 82 | +The underlying data is available as part of R package datasets. The version used is distributed with R 4.5.0. This version is a simplified |
| 83 | +of the original data collected by Azzalini, A. and Bowman, A. W. (1990). See metadata.md in the `data` directory for more information. |
| 84 | + |
| 85 | +Cite this work as: Brun, J., Janée, G., & Curty, R. G. (2025). Example Shiny application adopting the recommendations from "Ten Quick Tips for Developing a Reproducible Shiny Application" [Computer software]. <https://github.com/UCSB-Library-Research-Data-Services/shiny-qt-examples> |
0 commit comments