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!

Part A: Your own data set

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”.

Exercise 01 (10 points)

Add at least one new input widget in the ui-part, for example a slider or a dropdown menu.

Exercise 02 (10 points)

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.

Exercise 03 (10 points)

In the server part, create at least one new reactive element that responds to the newly created input widgets.

Exercise 04 (10 points)

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.

Exercise 05 (10 points)

Host your modified app on www.shinyapps.io and share the link when you submit your assignment via email..

Part B: Agricultural Statistics

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”.

Exercise 06 (10 points)

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.

Exercise 07 (10 points)

Change the reactive expression that defines “data_sel()” so it responds to the newly created input objects.

Exercise 08 (10 points)

Change the mainPanel() part so there is a new plot window at the right side of the leaflet map.

Exercise 09 (10 points)

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.

Exercise 10 (10 points)

Create a new download button with which one can download the entire agricultural statistics data set (and not just the selected data).