Whether you’re here
in your Shiny journey:
Photo by Andriyko Podilnyk on Unsplash
bslib
- add themes, components, and layouts with easethematic
- extends your Shiny theme to plotsshinyuieditor
- a visual tool to help create the UI portion of your Shiny app
“But my app runs great on my laptop…”
Two sides to this coin:
📣 Design principle: Make your app a lightweight presentation layer
Performance workflow:
message
statements or use log4r
packageshinyloadtest
to simulate app performance under loadprofvis
to profile your app to identify bottlenecks🧰 References:
materials/project/04_inspector_shiny_app/app.R
Activity
👉 Open the file materials/activities/activity-07_shiny.qmd
Runtime settings
Min processes — Keep a process running on the server at all times?
Max processes — Put a bound on the number of processes spawned?
Connections per process — A connection = a browser tab. How many connections will share the same process? Call this n
Load factor — Much like min processes, how early do you want to start a new process for that n + 1 connection?
The Shiny Restaurant Analogy
Let’s say you are the manager of a restaurant, and you need to determine two things:
The Shiny Restaurant Analogy
Managing Content
connectwidgets
for content curation Incorporate into a stylized R Markdown or Quarto document or Shiny application.
# Establish a connection to the Connect Server
client <- connect(
server = Sys.getenv("CONNECT_SERVER"),
api_key = Sys.getenv("CONNECT_API_KEY")
)
# Return a dataframe of content information to curate
project_content <- client |>
content() |>
# filter helpers:
by_tag() |>
by_owner() |>
# or use your own dplyr filter
dplyr::filter()
# Use widgets to lay out your content
### card
project_content |>
rsc_card()
### grid
project_content |>
rsc_grid()
### table
project_content %>%
rsc_table()
Tip
Content returned by connectwidgets::content
will be scoped to the API key provided.
https://colorado.posit.co/rsc/chicago-food-r/
Activity
👉 Open the file materials/activities/activity-08_Connectwidgets.qmd
🧰 Posit Connect Server API
Most endpoints require an API Key, and results will be scoped to the permissions of the key.
Helpful to publishers:
Helpful to admins:
See full documentation at https://docs.posit.co/connect/api/
See more examples: https://solutions.posit.co/operations/connect-apis/
curl
- Linux tool for making HTTP callshttr
- R HTTP libraryrequests
- Python HTTP libraryconnectapi
R package, which provides a wrapper around HTTP requestsconnectapi
that is a wrapper around the API https://pkgs.rstudio.com/connectapi/