Homework 6
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, and make sure all checks pass.
Question 1
Country populations (animated).
Recreate the plot you used for this exercise from hw-04 on country populations. The data come from The WorldBank. The dataset you will use is in your data/
folder and it’s called country-pop.csv
. This time, make sure to use only values from actual countries.
Load the two dataset using
read_csv()
.- You will need to use the
skip
argument since the CSV file has some extraneous rows on top. First load the data without it, then determine how many rows to skip. - Make sure there are no extraneous columns by removing them.
- Use
janitor::clean_names()
- You will need to use the
Find the countries with the top 10 highest population count in 2020. Subset the data for just these 10 countries.
Create a racing bar chart, using gganimate for the change in population for these countries. Attempt a different animation layer this time.
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 aslife_meaning.csv
in the data folder.
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 created, 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 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 R Markdown folder.
- If you have a dataset you’ve created and placed in the
data
folder in the root of your project/repo, move that data file into theapp1/data
folder. You need everything needed to run the app in theapp1
folder for deployment. This creates multiple copies of the data in your repo, but that’s ok. If you don’t have a dataset - Note: 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 R Markdown folder.