1. Learn
  2. /
  3. Courses
  4. /
  5. Case Studies: Building Web Applications with Shiny in R

Connected

Exercise

Download the filtered data

Downloading files is achieved using the pair of functions downloadButton() and downloadHandler(). These two functions pair together similarly to how output and render functions are paired: downloadButton() determines where in the UI it will show up, while downloadHandler() needs to be saved into the output list and has the actual R code to create the downloaded file.

Instructions

100 XP

Add the ability to download the data that is currently viewed in the table as a CSV file. Specifically:

  • Add a download button to the UI with ID "download_data" and a label of "Download".
  • Add a download handler to the server (line 31).
  • Give the downloaded file a name of "gapminder_data.csv" (line 33).
  • Write the filtered data into a CSV file (line 50).