Shiny is a package in R that helps you build interactive web apps easily without needing to know web programming languages.
Click to reveal answer
beginner
What are the two main parts of a Shiny app?
A Shiny app has two main parts: UI (user interface) which controls what the user sees, and server which controls how the app works behind the scenes.
Click to reveal answer
beginner
What function is used to create the user interface in Shiny?
The function fluidPage() is commonly used to create a simple and responsive user interface in Shiny apps.
Click to reveal answer
intermediate
How do you make a Shiny app respond to user input?
You use input widgets like sliderInput() or textInput() in the UI, and then use input$widgetId in the server to react to what the user selects or types.
Click to reveal answer
beginner
What function runs a Shiny app?
The function shinyApp(ui, server) runs the app by connecting the UI and server parts together.
Click to reveal answer
Which two components are essential to build a Shiny app?
AHTML and CSS
BInput and Output files
CDatabase and API
DUI and server
✗ Incorrect
A Shiny app needs a UI to show the interface and a server to handle the logic.
What does the function sliderInput() do in Shiny?
ACreates a slider for user input
BDisplays a plot
CRuns the app
DSaves data to a file
✗ Incorrect
sliderInput() creates a slider widget so users can pick a number by sliding.
How do you access the value of an input widget named 'age' in the server function?
Aage$input
Binput$age
Coutput$age
Dserver$age
✗ Incorrect
Input values are accessed using input$widgetId, so here it is input$age.
Which function is used to create a fluid and responsive UI layout in Shiny?
AfluidPage()
BfixedPage()
CrunApp()
DrenderUI()
✗ Incorrect
fluidPage() creates a flexible layout that adjusts to screen size.
What does the server function in Shiny do?
AStarts the web server
BDefines the app's appearance
CControls the app's logic and reactions to user input
DStores user data permanently
✗ Incorrect
The server function contains the code that reacts to user input and updates outputs.
Explain the roles of the UI and server parts in a Shiny app.
Think about what the user interacts with versus what happens behind the scenes.
You got /4 concepts.
Describe how you would create a simple Shiny app that takes a number input and shows it doubled.
Focus on input widgets, accessing input, and showing output.
You got /4 concepts.
Practice
(1/5)
1. In a Shiny app, what is the main role of the ui part?
easy
A. To perform calculations and data processing
B. To define what the user sees and interacts with
C. To store data permanently
D. To connect to external databases
Solution
Step 1: Understand the purpose of ui in Shiny
The ui defines the layout and elements the user interacts with, like buttons and plots.
Step 2: Differentiate from server role
The server handles logic and calculations, not the ui.
Final Answer:
To define what the user sees and interacts with -> Option B
Quick Check:
ui = user interface [OK]
Hint: Remember UI means User Interface, what users see [OK]
Common Mistakes:
Confusing ui with server
Thinking ui does data processing
Assuming ui stores data
2. Which of the following is the correct way to create a numeric input in Shiny's UI?
easy
A. numericInput(inputId = "num", label = "Number", value = 0)
B. numericInput("Number", inputId = "num", value = 0)
C. numericInput(0, "Number", 0)
D. numericInput(label = "Number", value = 0)
Solution
Step 1: Recall numericInput syntax
The correct order is numericInput(inputId, label, value).
Step 2: Check each option
numericInput(inputId = "num", label = "Number", value = 0) matches the correct syntax exactly; others have wrong argument order or missing arguments.
Final Answer:
numericInput(inputId = "num", label = "Number", value = 0) -> Option A
Quick Check:
Correct argument order = numericInput(inputId = "num", label = "Number", value = 0) [OK]
Hint: Remember inputId first, then label, then value [OK]
Common Mistakes:
Mixing argument order
Omitting inputId
Using unnamed arguments incorrectly
3. What will be the output shown in the Shiny app if the server code is:
The code uses data inside plot() but data is not defined anywhere.
Step 2: Understand consequences of missing data
This will cause an error because R cannot find the object data.
Final Answer:
Missing definition of 'data' causes an error -> Option A
Quick Check:
Undefined variable = error [OK]
Hint: Always define variables before using in render functions [OK]
Common Mistakes:
Assuming plot() is invalid in renderPlot
Confusing output variable names
Thinking renderPlotly is required
5. You want to create a Shiny app that shows a histogram of a numeric variable chosen by the user from a dropdown menu. Which approach correctly connects the input and output?
hard
A. Use sliderInput to select variable, then plot histogram of entire data
B. Use numericInput for variable choice, then plot fixed variable in server
C. Use selectInput in UI for variable choice, then in server use renderPlot to plot histogram of data[[input$var]]
D. Use textInput for variable name, then plot histogram of input$var directly
Solution
Step 1: Choose correct input control for variable selection
selectInput lets user pick a variable name from choices.
Step 2: Use input to select data column in server
Access the chosen variable as data[[input$var]] and plot histogram with renderPlot.
Final Answer:
Use selectInput in UI for variable choice, then in server use renderPlot to plot histogram of data[[input$var]] -> Option C
Quick Check:
Dropdown input + dynamic plot = Use selectInput in UI for variable choice, then in server use renderPlot to plot histogram of data[[input$var]] [OK]
Hint: Use selectInput for choices, access with data[[input$var]] [OK]
Common Mistakes:
Using numericInput instead of selectInput
Trying to plot input$var directly without data
Using sliderInput for variable selection
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.