Quiz 1 Developing Data Products (Data Science Specialization) Answers 2025
-
Question 1 — Which are absolutely necessary for a functioning Shiny app? (check all that apply)
✅ A server.R file containing a call to shinyServer()
❌ A server.R file that sets configuration options for hosting the App
❌ A shiny.R file containing calls to shinyServer() and shinyUI()
✅ A ui.R file containing a call to shinyUI()
❌ A ui.R file that contains information about the CSS and styling of the App
Explanation:
A basic Shiny app (using the two-file approach) requires a ui.R (with shinyUI(...)) and a server.R (with shinyServer(function(input, output){...})). Files that merely hold hosting configuration or CSS are not required. (app.R is an alternative single-file format — shiny.R is not a standard required filename.)
-
Question 2 — What is incorrect about this
ui.Rsyntax?
✅ Missing a comma in the sidebar panel
❌ The h2 command should be an h3 command
❌ Missing comma after the h3 command
❌ The h2 command does not take text arguments
Explanation:
Inside sidebarPanel( h2('Big text') h3('Sidebar') ) there is no comma between h2('Big text') and h3('Sidebar') — that missing comma causes a syntax error. The other choices are not the primary syntax problem.
-
Question 3 — Why isn’t it doing what we want? (check all that apply)
✅ The server.R output name isn’t the same as the plotOutput command used in ui.R.
✅ The limits of the slider are set incorrectly and giving an error.
❌ It should be mu <- input$mean in server.R
❌ The phrase “Guess at the mu value” should say “mean” instead of “mu”
Explanation:
Two problems appear in the supplied code: (1) ui.R uses plotOutput('newHist') while server defines output$myHist <- renderPlot(...) — IDs must match. (2) The sliderInput call in the UI shows a trailing comma step = 0.05, ) — that trailing comma will cause an error in R (so the slider definition is invalid). The mu <- input$mean remark is wrong — the input id in UI is mu, so input$mu is correct. The label text wording doesn’t affect code execution.
-
Question 4 — Main differences between a Shiny Gadget and a regular Shiny App? (check all that apply)
❌ Shiny Gadgets are specially designed for use on mobile phones and tablet computers.
✅ Shiny Gadgets are designed to have small user interfaces that fit on one page.
✅ Shiny Gadgets are designed to be used by R users in the middle of a data analysis.
❌ Shiny Gadgets are smaller programs and therefore run faster than Shiny Apps.
✅ Shiny Gadgets can be run on a user’s personal computer, unlike a regular Shiny App which needs to be hosted online.
Explanation:
Shiny Gadgets (with miniUI) are intended as compact tools for interactive, in-session use by R users (e.g., in RStudio). They’re typically local and small UX. Claims about mobile focus or inherent speed are incorrect; and while regular Shiny apps are often hosted, they can also be run locally — the choice was included to highlight local vs hosted use for typical workflows.
-
Question 5 — Why isn’t
pickXY()doing what we want?
✅ No arguments are defined for pickXY()
❌ The input data is defined in such a way that it is not compatible with pickXY()
❌ The call to plot() references the column names of the data frame in the wrong order.
❌ The wrong column names are passed to brushedPoints()
Explanation:
The provided pickXY <- function() { ui <- miniPage(...) } shows a gadget factory with no parameters — typically a point-selection gadget expects a data object (or column names) as an argument so it knows what to plot and what to brush. Among the given choices, the lack of function arguments is the direct reason it can’t be used generically. (The other options may be real bugs in some implementations, but the snippet shows the missing-arguments issue.)
🧾 Summary Table
| Q# | ✅ Correct Answer(s) | Key concept |
|---|---|---|
| 1 | server.R contains shinyServer() ✅, ui.R contains shinyUI() ✅ |
Basic Shiny app needs matched ui.R + server.R (or single app.R) |
| 2 | Missing a comma in the sidebar panel ✅ | Syntax: commas between UI elements |
| 3 | output name mismatch ✅, trailing comma in slider (invalid) ✅ |
IDs must match; UI function calls must be syntactically valid |
| 4 | Gadgets: small UI ✅, for R users mid-analysis ✅, run locally ✅ | Gadgets = compact, interactive tools for local/in-session use |
| 5 | pickXY() lacks arguments ✅ |
Gadget function should accept data/parameters — otherwise unusable |