App-packages

Published

2024-12-20

Expand the callout boxes below to review what we’ve covered in the last four chapters:

1  Whole app game walks through the ‘whole game’ of the app-package development workflow. The application in this example comes from the Packages chapter of Mastering Shiny.

The applications in Chapter 1 (Whole app game) can be accessed with the launch() or get() functions from the shinypak R package:

# install.packages('pak')
pak::pak('mjfrigaard/shinypak')
library(shinypak)

Chapter 1 applications:

list_apps(regex = '^01')
## # A tibble: 1 × 2
##   branch            last_updated       
##   <chr>             <dttm>             
## 1 01_whole-app-game 2024-07-30 07:59:35

The Shiny chapter covered

  1. Basic Shiny projects (2.1 Shiny projects )

  2. Shiny app folders (2.3 Folders) and files (2.4 Files)

  3. Shiny modules (2.5.1 Modules) and standalone app functions (2.5.2 Standalone app function), and

  4. Other ‘pre-package’ advanced practices (2.6 Additional features) you may have adopted in your Shiny app.

The applications in Chapter 2 (Shiny) can be accessed with the launch() or get() functions from the shinypak R package:

# install.packages('pak')
pak::pak('mjfrigaard/shinypak')
library(shinypak)

Chapter 2 applications:

list_apps(regex = '^02')
## # A tibble: 3 × 2
##   branch          last_updated       
##   <chr>           <dttm>             
## 1 02.1_shiny-app  2024-09-03 14:27:18
## 2 02.2_movies-app 2024-12-15 04:14:20
## 3 02.3_proj-app   2024-12-15 22:00:36

Packages illustrates what separates R projects from R packages. This chapter covers:

  1. The essential ingredients of an R package (3.1.1 Essential ingredients)

  2. How to create a new Shiny app-package (3.2.1 New app-packages) and

  3. Convert an existing Shiny app (3.2.2 Converting a Shiny project) into an app-package.

The applications in Chapter 3 (Packages) can be accessed with the launch() or get() functions from the shinypak R package:

# install.packages('pak')
pak::pak('mjfrigaard/shinypak')
library(shinypak)

Chapter 3 applications:

list_apps(regex = '^03')
## # A tibble: 3 × 2
##   branch              last_updated       
##   <chr>               <dttm>             
## 1 03.1_description    2024-12-16 12:57:01
## 2 03.2_rproj          2024-12-16 12:58:34
## 3 03.3_create-package 2024-12-17 14:56:55

4  Development introduced the devtools package and its core functions:

  1. load_all() (4.2 Load)

  2. document() (4.3 Document), and

  3. install() (4.4 Install)

The applications in Chapter 2 (Development) can be accessed with the launch() or get() functions from the shinypak R package:

# install.packages('pak')
pak::pak('mjfrigaard/shinypak')
library(shinypak)

Chapter 4 applications:

list_apps(regex = '^04')
## # A tibble: 1 × 2
##   branch      last_updated       
##   <chr>       <dttm>             
## 1 04_devtools 2024-09-03 22:01:57

App-packages

The following chapters will continue with app-package development, emphasizing developing a Shiny application within a package structure. A preview of each topic covered in the upcoming chapters is provided below.

Documentation (Chapter 5)

5  Documentation covers documenting the code in your app-package with roxygen2:

  • Required tags: @title, @description, @details, @param, @return, and @examples
  • App-package tags for modules and standalone app functions: @seealso, @family, and @section

Dependencies (Chapter 6)

6  Dependencies dives into the external (i.e. add-on) functions and packages you’ve used to build your app-package. We’ll also cover how to export functions and objects from your app-packages for others to use.

  • Exporting functions from your package namespace
    • @export/export()
  • Importing functions from add-on packages into your package namespace
    • NAMESPACE directives
    • The Imports field in the DESCRIPTION

Data (Chapter 7)

7  Data covers how to include datasets in your app-package namespace, and the various kinds of data in R packages.

  • Documenting data with roxygen2 using @format, \describe, \item

  • Location of data files: data/ vs. data-raw/ vs. inst/extdata/

Launch (Chapter 8)

The 8  Launch chapter covers how to 1) run your application during development, 2) how to run your app using a standalone app function, and 3) how to deploy your application to shinyapps.io.

  • What goes in app.R?
    • shinyApp() vs. shinyAppDir() vs. runApp()
    • rsconnect::deployApp()

External files (Chapter 9)

9  Resources covers how to include external resources (i.e. the images, CSS, html, or other files that are typically included in the www/ folder and served when you run your Shiny app). This chapter also covers other uses for the isnt/ folder in app-packages.

  • www/ vs. inst/

  • Using addResourcePath() with system.file()

Please open an issue on GitHub