Lecture 23
Cornell University
INFO 3312/5312 - Spring 2025
April 22, 2025
Every Shiny app has a webpage that the user visits,
and behind this webpage there is a computer that serves this webpage by running R (or Python!).
When running your app locally, the computer serving your app is your computer.
When your app is deployed, the computer serving your app is a web server.
#| standalone: true
#| viewerHeight: 700
library(shiny)
library(bslib)
# Define UI ----
ui <- page_fluid(
sliderInput(
inputId = "num",
label = "Choose a number",
min = 0, max = 100,
value = 20)
)
# Define server logic ----
server <- function(input, output) {
}
# Run the app ----
shinyApp(ui = ui, server = server)
<div class="form-group shiny-input-container">
<label class="control-label" id="num-label" for="num">Choose a number</label>
<input class="js-range-slider" id="num" data-skin="shiny" data-min="0" data-max="100" data-from="20" data-step="1" data-grid="true" data-grid-num="10" data-grid-snap="false" data-prettify-separator="," data-prettify-enabled="true" data-keyboard="true" data-data-type="number"/>
</div>
Function | Outputs |
---|---|
plotOutput() |
plot |
tableOutput() |
table |
uiOutput() |
Shiny UI element |
textOutput() |
text |
#| standalone: true
#| viewerHeight: 700
library(shiny)
library(bslib)
# Define UI ----
ui <- page_fluid(
sliderInput(
inputId = "num",
label = "Choose a number",
min = 0, max = 100,
value = 20
),
plotOutput("myplot")
)
# Define server logic ----
server <- function(input, output) {
}
# Run the app ----
shinyApp(ui = ui, server = server)
Modern UI toolkit for Shiny based on Bootstrap:
Creation of delightful and customizable Shiny dashboards with cards, value boxes, sidebars, etc.
Use of modern versions of Bootstrap and Bootswatch
Learn more at https://rstudio.github.io/bslib
ae-22
Instructions
ae-22
(repo name will be suffixed with your GitHub name).renv::restore()
to install the required packages, open the Quarto document in the repo, and follow along and complete the exercises.Instructions
age-rule
folder, and launch the app by opening the app.R
file and clicking on Run App.Instructions