HW 06 - Baby name trends

Homework
Modified

April 16, 2024

Important

This homework is due Wednesday, April 24 at 11:59pm ET.

Getting started

  • Go to the info3312-sp24 organization on GitHub. Click on the repo with the prefix hw-06. It contains the starter documents you need to complete the lab.

  • Clone the repo and start a new project in RStudio.

Packages

library(tidyverse)
library(shiny)
library(bslib)

Guidelines + tips

As we’ve discussed in lecture, your plots should include an informative title, axes should be labeled, and careful consideration should be given to aesthetic choices.

Remember that continuing to develop a sound workflow for reproducible data analysis is important as you complete this homework and other assignments in this course. There will be periodic reminders in this assignment to remind you to render, commit, and push your changes to GitHub. You should have at least 3 commits with meaningful commit messages by the end of the assignment.

Workflow + formatting

Make sure to

  • Update author name on your document.
  • Label all code chunks informatively and concisely.
  • Follow the Tidyverse code style guidelines.
  • Make at least 3 commits.
  • Resize figures where needed, avoid tiny or huge plots.
  • Turn in an organized, well formatted document.

Studying popularity of baby names

For this set of exercises, we are going to use the babynames dataset. The original package has not been updated since 2017. The data folder contains four files that follow the exact same structure as babynames::babynames and includes births through 2020 courtesy of Frank Kovacs.

  • babynames: For each year from 1880 to 2020, the number of children of each sex given each name. All names with more than 5 uses are given.1

  • applicants: The number of applicants for social security numbers (SSN) for each year for each sex.2

  • lifetables: Cohort life tables data3

It also includes the following data set from the US Census:

  • births: Number of live births by year, up to 2020.4

You may need to use multiple files, but the most important one is babynames.csv. Feel free to bring in additional data sources as you wish.

Exercise 1

Create a traditional Quarto dashboard to report on baby naming trends. Design and implement a Quarto dashboard that uses only client-side interactivity (i.e. no Shiny).

  • Make appropriate usage of Quarto layouts (e.g. sidebars, pages, panels, tabs) for your specific dashboard.
  • The dashboard should include at least one plot, one table, and one value box.
  • You should use plotly for at least one plot and customize it to maximize its interactivity.
  • Use an appropriate theme for styling. Feel free to further customize with CSS/SCSS if you have background knowledge, but it’s not required.
  • The dashboard should be published using GitHub Pages and the URL for the working dashboard clearly printed in your rendered PDF so we can easily access it during the evaluation.
Publishing a dashboard using GitHub Pages

In order to publish the dashboard, the output files must be rendered into the docs/ folder. Unfortunately Quarto 1.4 does not allow you to render individual files to a separate location. This means that if you have a Shiny app in the same project, you will not be able to render the dashboard to the docs/ folder. Quarto 1.5+ does allow users to render individual files to a specific output folder, but we do not have that installed on RStudio Workbench since it is still in pre-release.

As a workaround for the assignment, your Quarto dashboard source code files must also be stored in the docs/ folder. This way, when you render the Quarto dashboard it will be rendered to the same location. You can then publish the docs/ folder to GitHub Pages.

Now is a good time to render, commit, and push. Make sure that you commit and push all changed documents and your Git pane is completely empty before proceeding.

Exercise 2

Quarto + Shiny dashboard

Create a Quarto + Shiny dashboard to report on baby naming trends. Design and implement a Quarto + Shiny dashboard that appropriately uses server-side interactivity.

Note

Create your Quarto + Shiny dashboard in the shiny folder with the provided template file.

  • There are tons of examples online of Shiny apps made using the babynames package. You may use them for design inspiration but your implementation must be original. Don’t directly copy code from examples, and if you draw on specific features and/or code be sure to cite it.
  • You must use at least two user inputs and three reactive outputs (e.g. plots, tables, text).
  • Create a basic dashboard, expect a basic grade. We’re looking for extending beyond the basics and some originality/creativity. Things you might think to incorporate into the dashboard:
    • User experience: e.g. layout (pages, tabs, arrangement of cards, etc.), design, etc.
    • Customization: e.g. color palettes, themes, fonts, customized theme() to blend ggplot2 plots with the dashboard theme, etc.
    • Interactivity: e.g. hover effects, click events, etc.
    • Data: e.g. more than just babynames.csv, additional data sources, data wrangling, etc.
    • Insights: e.g. text boxes, value boxes, etc.
  • The dashboard should be published using Shinyapps.io and the URL for the working app clearly printed in your rendered PDF so we can easily access it during the evaluation. You will need to create an account on Shinyapps.io but the free tier should be sufficient for this assignment.
Tip

You’ve learned about Shiny in class, but we haven’t covered deployment, so completing this exercise will require a bit of self-learning. See this article on deployment for instructions) for instructions for deployment to shinyapps.io, and ask questions if you need further guidance!

Render, commit, and push one last time.

Make sure that you commit and push all changed documents and your Git pane is completely empty before proceding.

Wrap up

Submission

Publish your static and Shiny dashboards

In order to evaluate your work, we need to see your working, published dashboards. Ensure they are published using the methods described above. In Gradescope, you should submit your rendered hw-06-shiny.pdf file which contains the viewable URLs and source code for each dashboard.

  • Go to http://www.gradescope.com and click Log in in the top right corner.
  • Click School Credentials \(\rightarrow\) Cornell University NetID and log in using your NetID credentials.
  • Click on your INFO 3312 course.
  • Click on the assignment, and you’ll be prompted to submit it.
  • Mark all the pages associated with exercise. All the pages of homework lab should be associated with at least one question (i.e., should be “checked”).

Grading

  • Exercise 1: 20 points
  • Exercise 2: 30 points
  • Total: 50 points