Module 33 Trump, Shiny, & Git

Learning goals

  • This is a review exercise: apply the dplyr, ggplot, git, and shiny skills introduced in the previous modules, as well as the skills from the Deep R modules on Working with Dates and Times and Working with Text to create an interactive dashboard for exploring Trump’s tweets.


1. Create a repository on github named trumpapp

2. Clone the trumpapp repository into a place on your computer where you’ll easily be able to find it.

3. Open a blank R script. Save it in the recently cloned trumpapp folder as app.R.

4. Copy-paste the below code into app.R

5. Run the app to make sure it works.

6. Replace the “My app title” with a title of your choosing.

7. Replace the h3('Hi, you should replace me') line with two “columns”, the latter twice the width of the former. For example:

8. In the column of width 4, add a “text input”. This is a place the user of the app can write anything they want.

9. In the server part of the app, after the data read-in section, create a “reactive” dataframe. A reactive dataframe is a dataframe that automatically adjusts based on user input. To do this, use the below code:

10. Create a plot output in the server. This should be named something like output$my_plot and should use the renderPlot({}) function. Make this plot be the number of times that the word/string searched for by the user appeared in Trump’s tweets, for each year month.

11. Refer to my_plot correctly in the UI so that the plot shows up. Test that the plot works.

12. Add a slider input to your app so that the user can filter down the date range of the period covered. Make sure the dates from the slider input are appropriately passed to your app.

13. Look up the datatable function. It is part of the DT library.

14. In the rawdata tab of your app, show the “raw” data of the tweets which match the text input from the user. You’ll need renderDataTable and dataTableOutput.

15. Add another slider which allows users to filter by time of day.

16. Push your code to github.

17. Publish your app to Send a link to your code and app to

18. You just made a cool Trump tweet data explorer, and you’re all done, and you’re waiting on everyone else to finish? Congratulations! Now make a Shakespeare data explorer. Good luck. ;)