Deadline

The homework is due Tuesday, November 21 2017.

What we’ve done

This week we create a Shiny app that lets you search for products from the BC Liquor Store based on price, alcohol type, and country. We used this dataset and this code for our app.

What you need to do

Build a new Shiny app

The app we developed is functional, but there are plenty of improvements that can be made. You can compare the app we developed to Dean’s version of this app to get an idea of what a more functional app could include. For the homework, you need to either develop a new Shiny app, using your preferred dataset (or one you want to know more about). If you are short on ideas, you can instead add 3 or more features to the BC Liquor Store app we developed together.

Building details

Regardless of whether you create a new app or just add new features to our BC Liquor Store app, you must do the following 5 things:

  1. Your app should be split into a ui.R file and a server.R file. Note that so far in class we only had our apps inside an app.R file. You can read this official Shiny help page if you need more help with this part.

  2. Your app should be deployed online on shinyapps.io. Make sure your app actually works online (sometimes your app will work in RStudio but will have errors on shinyapps.io - make sure you deploy early and often to make debugging easier).
    • If you want to really challenge yourself, you can try getting your own Shiny Server and host your app yourself. Read this tutorial for help on setting that up.
  3. Add a README.md file to your Shiny app folder in your course repository. In the README.md you should describe your app and add a link to the URL where the app is hosted.

  4. Include the code for your Shiny app in your repository, as the marker will need to review your code.

  5. Whatever dataset you will use, acknowledge its source clearly and extensively. 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.

Possible features for the BC Liquor Store app.

If you decide to create a new app, then you are free to do whatever you want - get creative! If you want to use the BC Liquor Store app, you need to add at least 3 new features to it. There are countless possibilities, but here are just a few ideas. Notice: you may want to read this and get inspired even if you’ll develop your own shiny app. You can choose any 3 or more ideas from this list or do anything else.

  • Add an option to sort the results table by price.
    • Hint: Use checkboxInput() to get TRUE/FALSE values from the user.
  • Add an image of the BC Liquor Store to the UI.
    • Hint: Place the image in a folder named www, and use img(src = "imagename.png") to add the image.
  • Use the DT package to turn the current results table into an interactive table.
    • Hint: Install the DT package, replace tableOutput() with DT::dataTableOutput() and replace renderTable() with DT::renderDataTable().
  • 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.
  • The app currently behaves strangely when the user selects filters that return 0 results. For example, try searching for wines from Belgium. There will be an empty plot and empty table generated, and there will be a warning message in the R console. Try to figure out why this warning message is appearing, and how to fix it.
    • Hint: The problem happens because renderPlot() and renderTable() are trying to render an empty data frame. To fix this issue, the filtered reactive expression should check for the number of rows in the filtered data, and if that number is 0 then return NULL instead of a 0-row data frame.
  • Place the plot and the table in separate tabs.
    • Hint: Use tabsetPanel() to create an interface with multiple tabs.
  • 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.
  • 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.
  • Show the number of results found whenever the filters change. For example, when searching for Italian wines $20-$40, the app would show the text “We found 122 options for you”.
    • Hint: Add a textOutput() to the UI, and in its corresponding renderText() use the number of rows in the filtered() object.
  • Allow the user to download the results table as a ..csv file.
    • Hint: Look into the downloadButton() and downloadHandler() functions.
  • When the user wants to see only wines, show a new input that allows the user to filter by sweetness level. Only show this input if wines are selected.
    • Hint: Create a new input function for the sweetness level, and use it in the server code that filters the data. Use conditionalPanel() to conditionally show this new input. The condition argument of conditionalPanel should be something like input.typeInput == "WINE".
  • Allow the user to search for multiple alcohol types simultaneously, instead of being able to choose only wines/beers/etc.
    • 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 argument multiple = TRUE to support choosing multiple options.
  • If you look at the dataset, you’ll see that each product has a “type” (beer, wine, spirit, or refreshment) and also a “subtype” (red wine, rum, cider, etc.). Add an input for “subtype” that will let the user filter for only a specific subtype of products. Since each type has different subtype options, the choices for subtype should get re-generated every time a new type is chosen. For example, if “wine” is selected, then the subtypes available should be white wine, red wine, etc.
    • Hint: Use uiOutput() to create this input in the server code.
  • Provide a way for the user to show results from all countries (instead of forcing a filter by only one specific country).
    • Hint: There are two ways to approach this. You can either add a value of “All” to the dropdown list of country options, you can include a checkbox for “Filter by country” and only show the dropdown when it is unchecked (see my version of this app to see this option in action). In both cases you’ll still need to update the server code appropriately to filter by country only when the user chooses to.

Resources

Don’t forget to check out some of the awesome resources for Shiny, they can really help you out.

Rubric

Your peer reviewer will evaluate your app based only on the Shiny app that you deploy and on the README.md file that described what you app does. Your peer reviewer will not download your code. Therefore, you really need to make sure your app works on shinyapps.io, otherwise your reviewer will not be able to give you a mark.

The course TA that will mark your assignment will also look at your code, so make sure you include the code for the app.

Check minus: The deployed app does not work or results in many errors. There is no README file describing what app does.

Check: Shiny app runs. The README file describes either a new app or 3+ additions to our BC Liquor Store app. Whatever is described in the README is actually implemented in the app.

Check plus: Amazing Shiny app. Lots of new features or a very cool new app idea. App looks great visually. App is deployed on a Shiny Server instead of on shinyapps.io.

Recall the general homework rubric.

Peer Review

The peer review is ready and is due November 24, 2017 (before midnight)! Here’s what you’ll need to do:

  1. Find your github username in the table below. If it’s not there, let Giulio know! Slack me @giulio.
  2. Add the people who will be giving you a review as collaborators to the repo containing your homework submission.
  3. Give a review of this homework for the two people you’ve been assigned to. There should be an issue in their repo titled something like hw0x ready for grading – put your review in there as a comment.
    • If there is no such issue, make one! (in their repo)
    • Please don’t mix up your reviewers and reviewees!

** If you were assigned to a MISSING repo, please contact me @gvdr **

** If you did not yet communicate me your github handle, please do **

Check out the guidelines for giving a peer review.

Your_github Instructions
abishekarun Please add Shirlett and Alexander-Morin as collaborators to your repo containing hw08. Please review the hw08 submission of zxkathy and yeonukkim.
Alexander-Morin Please add Mathnstein and Shirlett as collaborators to your repo containing hw08. Please review the hw08 submission of abishekarun and zxkathy.
AnhKhoaVo Please add juansbr7 and swynes as collaborators to your repo containing hw08. Please review the hw08 submission of santiagodr and hannahdxz.
arsbar24 Please add ZimingY and heathersummers as collaborators to your repo containing hw08. Please review the hw08 submission of jmurthy12 and HScheiber.
arthursunbao Please add wswade2 and suminwei2772 as collaborators to your repo containing hw08. Please review the hw08 submission of farihakhan and Tangjiahui26.
bcahn7 Please add sepkamal and Kozp as collaborators to your repo containing hw08. Please review the hw08 submission of wenzhengzzz and xinyaofan.
CassKon Please add peterwhitman and ilgan as collaborators to your repo containing hw08. Please review the hw08 submission of cheungamanda and vanflad.
cheungamanda Please add ilgan and CassKon as collaborators to your repo containing hw08. Please review the hw08 submission of vanflad and margotgunning.
dorawyy Please add gbraich and rishadhabib as collaborators to your repo containing hw08. Please review the hw08 submission of marbazua and SonjaS1.
emilymistick Please add rainerlempert and xinmiaow as collaborators to your repo containing hw08. Please review the hw08 submission of emwest and hsmohammed.
emwest Please add xinmiaow and emilymistick as collaborators to your repo containing hw08. Please review the hw08 submission of hsmohammed and Mathnstein.
farihakhan Please add suminwei2772 and arthursunbao as collaborators to your repo containing hw08. Please review the hw08 submission of Tangjiahui26 and gbraich.
gbraich Please add farihakhan and Tangjiahui26 as collaborators to your repo containing hw08. Please review the hw08 submission of rishadhabib and dorawyy.
hannahdxz Please add AnhKhoaVo and santiagodr as collaborators to your repo containing hw08. Please review the hw08 submission of yanchaoluo and vibudh2209.
heathersummers Please add mylinhthibodeau and ZimingY as collaborators to your repo containing hw08. Please review the hw08 submission of arsbar24 and jmurthy12.
HScheiber Please add arsbar24 and jmurthy12 as collaborators to your repo containing hw08. Please review the hw08 submission of juansbr7 and swynes.
hsmohammed Please add emilymistick and emwest as collaborators to your repo containing hw08. Please review the hw08 submission of Mathnstein and Shirlett.
ilgan Please add yuanjisun and peterwhitman as collaborators to your repo containing hw08. Please review the hw08 submission of CassKon and cheungamanda.
jmurthy12 Please add heathersummers and arsbar24 as collaborators to your repo containing hw08. Please review the hw08 submission of HScheiber and juansbr7.
juansbr7 Please add jmurthy12 and HScheiber as collaborators to your repo containing hw08. Please review the hw08 submission of swynes and AnhKhoaVo.
KateJohnson Please add yeonukkim and qiaoyuet as collaborators to your repo containing hw08. Please review the hw08 submission of yuanjisun and peterwhitman.
Kozp Please add menglinzhou and sepkamal as collaborators to your repo containing hw08. Please review the hw08 submission of bcahn7 and wenzhengzzz.
marbazua Please add rishadhabib and dorawyy as collaborators to your repo containing hw08. Please review the hw08 submission of SonjaS1 and rainerlempert.
margotgunning Please add cheungamanda and vanflad as collaborators to your repo containing hw08. Please review the hw08 submission of yidie and mlawre01.
Mathnstein Please add emwest and hsmohammed as collaborators to your repo containing hw08. Please review the hw08 submission of Shirlett and Alexander-Morin.
mattsada Please add mlawre01 and vmichalowski as collaborators to your repo containing hw08. Please review the hw08 submission of mylinhthibodeau and ZimingY.
menglinzhou Please add yanchaoluo and vibudh2209 as collaborators to your repo containing hw08. Please review the hw08 submission of sepkamal and Kozp.
mlawre01 Please add margotgunning and yidie as collaborators to your repo containing hw08. Please review the hw08 submission of vmichalowski and mattsada.
mylinhthibodeau Please add vmichalowski and mattsada as collaborators to your repo containing hw08. Please review the hw08 submission of ZimingY and heathersummers.
peterwhitman Please add KateJohnson and yuanjisun as collaborators to your repo containing hw08. Please review the hw08 submission of ilgan and CassKon.
qiaoyuet Please add zxkathy and yeonukkim as collaborators to your repo containing hw08. Please review the hw08 submission of KateJohnson and yuanjisun.
rainerlempert Please add marbazua and SonjaS1 as collaborators to your repo containing hw08. Please review the hw08 submission of xinmiaow and emilymistick.
rishadhabib Please add Tangjiahui26 and gbraich as collaborators to your repo containing hw08. Please review the hw08 submission of dorawyy and marbazua.
santiagodr Please add swynes and AnhKhoaVo as collaborators to your repo containing hw08. Please review the hw08 submission of hannahdxz and yanchaoluo.
sepkamal Please add vibudh2209 and menglinzhou as collaborators to your repo containing hw08. Please review the hw08 submission of Kozp and bcahn7.
Shirlett Please add hsmohammed and Mathnstein as collaborators to your repo containing hw08. Please review the hw08 submission of Alexander-Morin and abishekarun.
SonjaS1 Please add dorawyy and marbazua as collaborators to your repo containing hw08. Please review the hw08 submission of rainerlempert and xinmiaow.
suminwei2772 Please add xinyaofan and wswade2 as collaborators to your repo containing hw08. Please review the hw08 submission of arthursunbao and farihakhan.
swynes Please add HScheiber and juansbr7 as collaborators to your repo containing hw08. Please review the hw08 submission of AnhKhoaVo and santiagodr.
Tangjiahui26 Please add arthursunbao and farihakhan as collaborators to your repo containing hw08. Please review the hw08 submission of gbraich and rishadhabib.
vanflad Please add CassKon and cheungamanda as collaborators to your repo containing hw08. Please review the hw08 submission of margotgunning and yidie.
vibudh2209 Please add hannahdxz and yanchaoluo as collaborators to your repo containing hw08. Please review the hw08 submission of menglinzhou and sepkamal.
vmichalowski Please add yidie and mlawre01 as collaborators to your repo containing hw08. Please review the hw08 submission of mattsada and mylinhthibodeau.
wenzhengzzz Please add Kozp and bcahn7 as collaborators to your repo containing hw08. Please review the hw08 submission of xinyaofan and wswade2.
wswade2 Please add wenzhengzzz and xinyaofan as collaborators to your repo containing hw08. Please review the hw08 submission of suminwei2772 and arthursunbao.
xinmiaow Please add SonjaS1 and rainerlempert as collaborators to your repo containing hw08. Please review the hw08 submission of emilymistick and emwest.
xinyaofan Please add bcahn7 and wenzhengzzz as collaborators to your repo containing hw08. Please review the hw08 submission of wswade2 and suminwei2772.
yanchaoluo Please add santiagodr and hannahdxz as collaborators to your repo containing hw08. Please review the hw08 submission of vibudh2209 and menglinzhou.
yeonukkim Please add abishekarun and zxkathy as collaborators to your repo containing hw08. Please review the hw08 submission of qiaoyuet and KateJohnson.
yidie Please add vanflad and margotgunning as collaborators to your repo containing hw08. Please review the hw08 submission of mlawre01 and vmichalowski.
yuanjisun Please add qiaoyuet and KateJohnson as collaborators to your repo containing hw08. Please review the hw08 submission of peterwhitman and ilgan.
ZimingY Please add mattsada and mylinhthibodeau as collaborators to your repo containing hw08. Please review the hw08 submission of heathersummers and arsbar24.
zxkathy Please add Alexander-Morin and abishekarun as collaborators to your repo containing hw08. Please review the hw08 submission of yeonukkim and qiaoyuet.