Welcome to the exercises of module 6! Please try to solve the following exercises, and if you do not remember how to write the code for certain things, have a look again at the previous scripts. Programming is about learning by doing! So, do not hesitate to look for help in the internet, too. Remember that there is almost always more than just one way to solve a problem in R!
Via e-mail, you received a folder with a CSV file (= your submitted data set) and a file called “app.R”. This R-file visualizes the data from the CSV-file. Please copy these files to the folder “Exercises_1_to_5” and change all further edits therein.
Please develop your app further by solving the following exercises. Make sure that the app is running locally on your computer after you have made your changes to the code. Do not forget to save all changes that you made in “app.R”.
Add at least one new input widget in the ui-part, for example a slider or a dropdown menu.
Add at least one new output object in the ui-part, for example a plot or a map. For this, you may add columns or fluid rows in the main panel.
In the server part, create at least one new reactive element that responds to the newly created input widgets.
Render at least one output object in the server part, for example a plot or a map. This could respond to the newly created reactive element.
Host your modified app on www.shinyapps.io and share the link when you submit your assignment via email..
The file “app.R” in the folder “Exercises_6_to_10” contains a simple shiny app to visualize the agricultural statistics of the file “agric_stats.csv”. Inside the file “app.R”, please complete the following five exercises. Make sure that the app is running locally on your computer after you have made your changes to the code. Do not forget to save all changes you made in “app.R”.
Create two new menu items: one to select between yield, sown area, harvested area and production, and a slider to select the data of a specific year.
Change the reactive expression that defines “data_sel()” so it responds to the newly created input objects.
Change the mainPanel() part so there is a new plot window at the right side of the leaflet map.
Use this new plot window to render a ggplot that shows the data of “data_sel()” in a bar plot, with one bar for each marz.
Create a new download button with which one can download the entire agricultural statistics data set (and not just the selected data).