Assessment - Presenting Results
Quiz
Get the quiz sheet for this module from the general Assessments page. Fill it in, then submit to the online grading system before the deadline.
Discussion
Take a look at some of the presentations your classmates created and provide feedback. Hopefully, by looking at the different examples and code, you get a good idea for what can be done.
Exercise
This week is another solo exercise. Post it by Wednesday evening so your classmates can look at it and comment. (Of course, feel free to improve further after that, based on what you learn from other examples).
For this exercise, you are asked to create a professional-looking graph and a professional looking table based on data you find online. This exercise will go into your portfolio.
For motivation take a quick look at Rafael Irizarry’s blog post (the author of the IDS book we’ve been using). You don’t need to read the blog post in detail, but skim through it. He shows how one can use R and ggplot to reproduce figures that look very similar to professional ones. You’ll see that it usually doesn’t require that many lines of code to get an outstanding looking figure!
We’ll try to do that ourselves.
Find a graph to reproduce
Find an interesting graph from a news website. The main requirements are that the original graph must be interesting and good looking (a basic scatter plot is not enough), AND that the graph is freely available online, not behind a pay-wall. Ideally, the data that went into making the graph should be available too. If it is not, you will have to go through the extra step of extracting the data from the graph using tools like DataThief or WebPlotDigitizer.
One suggestion is to look at graphs from FiveThirtyEight. They are known to produce high-quality graphs, and for some of their stories and figures, they also provide the original data source. Good starting points for a chart from FiveThirtyEight might be their annual summaries of weirdest charts, which you can find here for 2015, 2016, 2018, 2019, 2020, 2021, 2022. (No, I don’t know why there’s no 2017.) Or you can go straight to their data, and see what graphs they produced with it and find a good one.
If you can’t find a graph on FiveThirtyEight that you like and would like to reproduce, you can also check out other major news outlets (USA Today, NY Times, Wall Street Journal, The Guardian, etc.).
Setup
This exercise will be part of your portfolio and will live in the presentation-exercise
folder. Place your data (see next) in that folder, and add your code and explanation to the Quarto starter file in that folder.
Get the data
As mentioned, you either need to have the data in a file, or you need to extract it from the graph and place it into a file. I recommend a CSV file. Place it into the presentation-exercise
folder.
Ask AI to re-create the original graph
Ask an AI of your choice (or try several) to re-create the original graph. I’m not sure what the best prompt is. You probably want to feed it the data and instructions on what kind of plot to make. I’m not sure if giving it the original plot, either as uploaded file or as a URL, will help. You can try. You will likely have to go through multiple iterations of asking the AI to update the code/figure.
You will likely want to use ggplot2 & friends, but if you want to use base R, lattice or another plotting approach that’s ok too, as long as everything happens with R code.
If you already feel comfortable making high-quality graphs with ggplot2
and want to try something different, feel free to create an interactive graph using one of the many options for that (e.g., Shiny, plotly). You can also recreate a previous static graph and make it interactive (e.g., allowing people to turn on/off specific parts).
Document (some of) your AI prompts in the visualization-exercise.qmd
Quarto file. Also show the code that the AI produced. Depending on how many iterations you do, you don’t need to show prompts and code for all intermediate steps. The AI will likely not get you all the way to where you want to get. Manually edit your code to try and get as close as possible to the original graph.
You should end up with a Quarto file that shows your AI prompts, possibly intermediate code that the AI returned, and finally a chunk of code that loads/takes the data and re-produces the original plot as closely as possible. Also show the original plot in youe Quarto file next/below your reproduction for comparison.
Create a publication quality table
For this part, the easiest approach is to use the same data you used for the graph (or a subset of the data) and create a nice looking table.
Alternatively, find a good-looking table somewhere online and try to recreate it. Of course, you need all data necessary to re-create the table. Often (but not always) that’s just the numbers in the table.
Again, start with AI. You can let it decide which R table package to use, or you can specify that as part of your prompt. Use whichever R table package you like. This tutorial shows how to make nice tables with the gt
package. Our group uses flextable a lot.
No matter what R package you use to make the table, it should look professional, visually pleasing, and nicely convey the information. For inspiration, you can for instance check out this R table gallery. The R graph gallery also has a section on tables.
As for the graphs, if you want to challenge yourself, you can try to make your table interactive. There are several good R packages that allow you to create interactive tables inside a Quarto document. Interactivity only works if your output format is HTML, it won’t work for pdf or word. But in your case it’s part of your website, so it’s HTML and can include interactivity.
Add the code and explanatory text (e.g., your AI prompts) into the same presentation-exercise.qmd
Quarto document. You should end up with code that takes some data and generates a nice-looking table.
Once all done, re-build your website and make sure that your data visualization exercise shows up nicely. Then, post the link to your online page showing your visualization into the discussion channel for this module. Do that by Wednesday so your classmates can take a look and comment by Friday.