HW 5

Shine bright like a diamond

For any exercise where you’re writing code, insert a code chunk and make sure to label the chunk. Use a short and informative label. For any exercise where you’re creating a plot, make sure to label all axes, legends, etc. and give it an informative title. For any exercise where you’re including a description and/or interpretation, use full sentences. Make a commit at least after finishing each exercise, or better yet, more frequently. Push your work regularly to GitHub. Once you’re done, inspect your GitHub repo to make sure you’ve pushed all of your changes.


Your homework repositories are set up to run a GitHub action every time you push to the repository checking for (1) any files that shouldn’t be in your repository or that should be in a specific folder in your repository and (2) whether your Quarto document renders.

If either of these checks fail, you’ll see a red badge on your repository README and you’ll get an email saying “check assignment” action has failed.

If they pass, you’ll see a green badge on your repository README and you won’t get an email saying.

Up until the deadline, it doesn’t matter how many times these checks fail. Just make sure by the end the badge is green.

Question 1

Mirror, mirror on the wall, who’s the ugliest of them all? Make a plot of the variables in the diamonds dataset from the ggplot2 package. Your plot should use at least two variables, but more is fine too.

  • First, make the plot using the default theme and color scales.

  • Then, update the plot to be as ugly as possible. You will probably want to play around with theme options, colors, fonts, etc. The ultimate goal is the ugliest possible plot, and the sky is the limit!

Your response must include two plots – the one with the default look and your “ugly” plot.

Use the following prompt for Questions 2-5.

Meaning of life. A 2021 Pew Research survey of 18,850 adults from 17 advanced economies (Canada, Belgium, France, Germany, Greece, Italy, the Netherlands, Spain, Sweden, the United Kingdom, the United States, Australia, Japan, New Zealand, Singapore, South Korea and Taiwan) asked the following question: “We’re interested in exploring what it means to live a satisfying life. What aspects of your life do you currently find meaningful, fulfilling or satisfying?” The results of the survey are summarized in the following visualization, which can be found on Pew’s summary of their findings.

Question 2

The data. Create a dataset based on the data presented in this visualization. You will want to take a peek at the next question, since the dataset you create / how the data are organized will depend on the type of visualization you might make in the next question.

  • The code to create the data should go in the data/data-create.R file.

  • The dataset should be called life_meaning and saved as life-meaning.csv in the data folder.

  • Once you create the data, read it in your Quarto document and run glimpse() on the data. A code chunk doing this is already provided for you, but it’s set to eval: false. Either remove this code chunk option (so the default, true, behavior kicks in) or set it to true.

Question 3

The visualization. Create an alternative visualization of these data. Accompany your visualization with a brief explanation of how you decided to create what you did, as well as how it is similar to and how it differs from the original visualization. It’s OK if your visualization is such that all the conclusions that can be drawn from the original visualization can’t be drawn from yours (e.g., maybe fewer choices per country are displayed), but this should be something you articulate in your answer along with a justification with why you think it’s OK to omit this feature. Make sure that your visualization employs accessibility best practices we’ve discussed in class, and write a sentence about features you’ve decided to include/omit to meet these guidelines. The code to make the visualization should go in your Quarto file (as usual).

Question 4

The app. Create a Shiny app that features the visualization you made in the previous question and at least one reactive element. The reactivity can be as simple as selecting a country to highlight. Deploy the app to shinyapps.io.

  • The code of the app should go in the app1 folder.

  • The link to the deployed app should be included in your Quarto document.

  • Place a copy of the dataset you’ve created and placed in the data folder in the root of your project/repo in the app1/data folder. You need everything needed to run the app in the app1 folder for deployment. This creates multiple copies of the data in your repo, but that’s OK.


You’ve learned about Shiny in class, but we haven’t covered deployment, so completing this question 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!

Question 5

The styled app. Change the look of your app using the theming features and the auto-theming option offered by the thematic package. This will allow the look of your app to match the look of your visualization. Deploy the app to Shinyapps.io.

  • The code of the app should go in the app2 folder.

  • The link to the deployed app should be included in your Quarto document.