Interactivity

Due by 11:59 PM on Monday, July 15, 2024

For this exercise, you’ll use whatever data you want to make a plot and make it interactive. Use a dataset from a past exercise, use one of the built-in datasets like mpg or gapminder from the {gapminder} package, download stuff from the World Bank using the {WDI} package, or use something from this list of datasets. Whatever you want.

THIS IS DIFFERENT

This exercise is a little different from past ones because you will not render to PDF or Word. Pay attention to the instructions below.

The example for this week’s session will be helpful as you tinker with ggplotly(), and the resources listed at the bottom of the example will be helpful for making a dashboard.

You’ll be doing all your R work in Quarto. You can download a zipped file of a pre-made project here:

And as always, if you’re struggling, please talk to me and use Slack and talk to your classmates! Don’t suffer in silence!

Instructions

  1. If you’re using R on your own computer, download this file, unzip it, and double click on the file named 11-exercise1.Rproj: 11-exercise.zip

    You’ll need to make sure you have these packages installed on your computer: tidyverse and plotly. If you try to load one of those packages with library(tidyverse) or library(plotly), etc., and R gives an error that the package is missing, use the “Packages” panel in RStudio to install it.

    (Alternatively, you can open the project named “Exercise 11” on Posit.cloud and complete the assignment in your browser without needing to install anything. This link should take you to the project—if it doesn’t, log in and look for the project named “Exercise 11”.)

  2. Rename the Quarto file named your-name_exercise-11.qmd to something that matches your name and open it in RStudio.

  3. Complete the tasks given in the Quarto file.

    Fill out code in the empty chunks provided (you can definitely copy, paste, and adapt from other code in the document or the example page—don’t try to write everything from scratch!).

  4. Here’s where this is all different this time. You will not upload a rendered PDF or Word file to iCollege, since those can’t handle interactivity. Instead, do this (there’s a video of this process below):

    1. Go to quartopub.com and create a free account. Make sure you’re logged in.

    2. Render the document with Tasks 1 and 2 in it to HTML.

    3. In the “Terminal” panel (not the Console panel) in RStudio, type this:

      quarto publish NAME_OF_YOUR_QMD.qmd
    4. Select “Quarto Pub”. You’ll be asked to authorize your computer if you haven’t already.

    5. Hit enter after each question until your browser opens with the rendered document

    6. Click on the link at the top of the page where it says “Published at https://YOURUSERNAME.quarto.pub/YOUR-DOCUMENT-NAME”. That’s a shareable URL.

    7. Render the dashboard from Task 3 to HTML and publish it to Quarto Pub using the same process. Take note of the URL.

    8. In iCollege, paste the two URLs into the submission form for exercise 11 following this template MAKE SURE that the URL does not start with https://quartopub.com; it needs to start with https://YOURUSERNAME.quarto.pub.

      Task 1 and 2: URL HERE
      Task 3 dashboard: URL HERE

Here’s what the process looks like: (see this and this for other examples)