Total Points: 100
For this assignment, you’ll be creating your own shiny app with three features, and deploying it.
The grading rubric is detailed at the very end. Note that we aren’t expecting a complex app for this assignment – a simple one is all we’re expecting.
Here are some examples of apps built with Shiny. We don’t expect you to achieve the level of complexity in any of these, but they are examples that may inspire you in terms of what you want to do with your own app!
Setup
Go to canvas to get your invitation to create a GitHub repository for this project. You can find this in the description of Assignment B-3. Name your repo as you wish, so long as it’s informative.
Feature ideas
There are countless possibilities for features, but here are just a few ideas. You can choose any 3 or more ideas from this list or do anything else! Want more ideas than what’s below? Check this out.
While (this year) you will be developing your own Shiny app from scratch instead of building on the BC Liquor App developed in Dean Attali’s tutorial, we will use the BC Liquor App as a running example of feature ideas for concreteness.
If you have a table in your app…
- Add an option to sort the table by one of your variables. For example, in the BC Liquor App, sorting the results by price.
- Hint: Use
checkboxInput()
to getTRUE
/FALSE
values from the user.
- Hint: Use
- Use the DT package to turn a static table into an interactive table.
- Hint: Install the DT package, replace
tableOutput()
withDT::dataTableOutput()
and replacerenderTable()
withDT::renderDataTable()
.
- Hint: Install the DT package, replace
- Show the number of results found whenever the filters change. For example, in the BC Liquor app, when searching for Italian wines
$20
-$40
, show the text “We found 122 options for you”.- Hint: Add a
textOutput()
to the UI, and in its correspondingrenderText()
use the number of rows in thefiltered()
object.
- Hint: Add a
- Allow the user to download your table as a .csv file.
- Hint: Look into the
downloadButton()
anddownloadHandler()
functions.
- Hint: Look into the
- Allow the user to search for multiple entries simultaneously; for example, in the BC Liquor app, allow the user to search for multiple alcohol types at once instead of wine/beer/etc, one at a time.
- Hint: There are two approaches to do this. Either change the typeInput radio buttons into checkboxes (
checkboxGroupInput()
) since checkboxes support choosing multiple items, or change typeInput into a select box (selectInput()
) with the argumentmultiple = TRUE
to support choosing multiple options.
- Hint: There are two approaches to do this. Either change the typeInput radio buttons into checkboxes (
If you have a plot in your app…
- Add parameters to the plot.
- Hint: You will need to add input functions that will be used as parameters for the plot. You could use
shinyjs::colourInput()
to let the user decide on the colours of the bars in the plot.
- Hint: You will need to add input functions that will be used as parameters for the plot. You could use
Other ideas:
- Add an image to the UI. For example, in the BC Liquor app, add an image of the BC Liquor Store. If you’re building your own app from scratch, an image may make your app more visually interesting or add information!
- Hint: Place the image in a folder named www, and use
img(src = "imagename.png")
to add the image.
- Hint: Place the image in a folder named www, and use
- If you know CSS, add CSS to make your app look nicer.
- Hint: Add a CSS file under www and use the function
includeCSS()
to use it in your app.
- Hint: Add a CSS file under www and use the function
- Experiment with packages that add extra features to Shiny, such as shinyjs, leaflet, shinydashboard, shinythemes, ggvis.
- Hint: Each package is unique and has a different purpose, so you need to read the documentation of each package in order to know what it provides and how to use it.
- If you have both a plot and a table, place them in separate tabs.
- Hint: Use
tabsetPanel()
to create an interface with multiple tabs.
- Hint: Use
Rubric
Shiny app development (75 points)
There are three features in your Shiny app. Clearly state which three features you are modifying or creating in your code, with comments. Specifically, write a sentence per feature explaining how it is useful. (60 pts, 20 per feature)
What are we looking for in your features?
- Variety. Including three tables as part of your dashboard and having the same exact feature for each of them (e.g. a filtering option, even if the tables are distinct) will be penalized; at least 2 of the 3 features must be unique.
- We will also evaluate the usefulness of your features in the context of your app (does it add to the user experience?). We expect your features to be sensible, meaning that they add to the user experience in a way that makes sense - as an example, adding a filtering option for “country” in a table that only has data for Canada does not seem very useful, even if you added the filtering feature correctly. If we consider any of your features to be irrelevant for the app, 2 pts will be penalized for that particular feature.
RRR (15 pts):
Tidy Submission (25 points)
Follow these steps to submit your work. Be sure to familiarize yourself with the rubric for a tidy submission below, before doing these steps.
-
- A link to a running instance of your Shiny app.
- A description of your app.
- Whatever dataset you will use, acknowledge its source clearly. Remember that we value open, reproducible science: this means that the user of your app should have direct access to the data, or know where to go to access it.
Acknowledgements
This homework was originally developed by Dean Attali, with modifications by Giulio Valentino Dalla Riva, and has been further modified for the current year.