Code

Expand the boxes below to review what was covered in previous three chapters:

The Docker chapter covered the following topics:

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

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

Chapter 15 applications:

list_apps(regex = '^15')
## # A tibble: 1 × 2
##   branch    last_updated       
##   <chr>     <dttm>             
## 1 15_docker 2024-07-03 13:39:23

Continuous integration and continuous deployment is demonstrated using GitHub Actions to automate three common workflows:

  • GitHub Actions are introduced with 16.1 Style workflow that styles and lints the code in your app-package when it’s pushed to Github.

  • The next section demonstrates using the 16.2 Shiny workflow, creating a renv lockfile for your app-package, and storing/setting your rsconnect account info.

  • The final section combines the previous chapter into a 16.3 Shiny & Docker workflow, which includes how to use a Dockerfile and a workflow file to launch you application.

The applications in Chapter 16 (CI/CD) can be accessed with the launch() or get() functions from the shinypak R package:

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

Chapter 16 applications:

list_apps(regex = '^16')
## # A tibble: 3 × 2
##   branch          last_updated       
##   <chr>           <dttm>             
## 1 16.1_gha-style  2024-07-03 13:46:30
## 2 16.2_gha-shiny  2024-05-23 15:07:23
## 3 16.3_gha-docker 2024-05-24 04:32:34
  • 17.1 Setup: covers creating a _pkgdown.yml configuration file that pkgdown uses to build the site for your app-package.

    • The _pkgdown.yml file also lets you customize how your website looks and which parts of your package are highlighted.
  • 17.2 Build demonstrates how build_site_github_pages() (or build_site()) tells pkgdown to go through your app-package, including the documentation, vignettes, and examples, and assemble them into a coherent, navigable website.

  • 17.3 Layouts briefly touches on the various ways you can customize your site (themes, fonts, and colors).

  • After building your site, you’ll need to deploy it with a 17.4 pkgdown workflow.

    • This also involves creating an orphan Git branch and pushing the pkgdown contents to GitHub Pages.

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

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

Chapter 17 applications:

list_apps(regex = '^17')
## # A tibble: 1 × 2
##   branch     last_updated       
##   <chr>      <dttm>             
## 1 17_pkgdown 2024-05-30 06:55:53

Shiny simplifies the creation of interactive web applications by allowing you to write R code that is automatically translated into HTML, CSS and JavaScript. However, sometimes it’s necessary to include non-R code files as supplemental resources to improve your application. This section will cover how to include HTML, CSS, and JavaScript files in your Shiny app-package.

We’ll also introduce an upgraded Shiny application in moviesApp. The updates include:

  1. A new layout using page_navbar() from bslib
    1. The UI outputs now sit in two nav_panel()s, with collapsible sidebars and footers.1
  2. Improved plots
    1. We’re using rlang’s injection operator (!!) for the plot inputs (instead of the .data masking), so the plotting modules now contain the ggplot2 functions used to create the graphs.
    2. A new plot label formatting function (label_titler()) makes it easier to convert variable inputs into title case.
  3. New graphs for viewing metrics by year and distributions
  4. A new standalone app function (launch_app()):

HTML

In HTML chapter, we’ll explore how to embed HTML within Shiny apps, use tags and functions to enhance UI layouts, and leverage HTML templates for more complex designs.

Additionally, we’ll cover how to seamlessly combine Shiny’s reactive outputs with custom HTML elements to build interactive interfaces.

CSS

The CSS chapter delves into the art of styling your Shiny applications, ensuring they are both visually appealing and user-friendly. We discuss how to apply custom styles to your app using CSS, enabling you to customize the appearance of your elements beyond Shiny’s default themes. You’ll learn how to include external CSS files, write inline styles, and utilize CSS frameworks like Bootstrap for responsive design. Through practical examples, we demonstrate how to manage CSS specificity, create reusable styles, and enhance the overall user experience by controlling layout, typography, colors, and animations.

JavaScript

In the JavaScript chapter, we cover how to extend the functionality of your Shiny applications with custom JavaScript. JavaScript can be used to handle client-side interactivity, manipulate the DOM, and integrate third-party libraries and APIs. We’ll show you how to include JavaScript files in your Shiny app-package, write custom JavaScript code that interacts with Shiny’s reactive model, and use Shiny’s JavaScript functions to create more dynamic and responsive applications. This chapter equips you with the skills to bridge the gap between Shiny’s R-based framework and the extensive capabilities of JavaScript, enhancing your app’s performance and user interaction.

Style

Style covers formatting the code in your package so it’s easier to debug (and read).


  1. bslib uses cards to display contents inside each nav_panel(). The outputs use card() with layout_sidebar(), card_body(), and card_footer(). Learn more on the bslib website.↩︎