1. Learn
  2. /
  3. Courses
  4. /
  5. Building Web Applications with Shiny in R

Connected

Exercise

Update output (server)

You are almost there! The final step is to update the plot output to display a line plot of prop vs. year, colored by sex, for the name that was input by the user. You can use this plot template to create your plot:

ggplot(subset(babynames, name == "David")) +
  geom_line(aes(x = year, y = prop, color = sex))

Recall that a user input named foo can be accessed as input$foo in the server. We have already pre-loaded the shiny and ggplot2 packages, as well as the babynames dataset.

Instructions

100 XP
  • Add the plotting code inside renderPlot(). Make sure to replace the hard-coded name (name == "David") with the name that was input by the user.