Welcome to the first Assignment! Try to solve the following exercises, and if you do not remember how to do code 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: Yield statistics

Exercise 01 (10 points)

Import the file with the yield data that corresponds to the crop assigned to your group from the folder “yield_by_crop”. You find the list of crops for each group in the file “M01_Overview.pptx”. Use the melt() function to re-organize the data so that all years are in one column, and all yield measurements are in one column. Transform the year-column into a numeric format.

Exercise 02 (10 points)

Using the function ggplot(), create a grouped bar plot of the yield data of your crop. Each marz should form one group, and each group should consist of three bars that represent the yield from the years 2005, 2010 and 2015. Export your plot as PNG.

Exercise 03 (10 points)

Create a multipart/facetted bar plot with ggplot(). Each facet should represent one marz. In each facet, each bar should represent the yield of your crop in one year from 2010 to 2020. Export your plot as PNG.

Exercise 04 (10 points)

Use spplot() to create a marz-level map of the yield of your crop in 2020. Export your map as PNG.

Exercise 05 (10 points)

Import the table “all_stats.csv” and select the entries corresponding to the crop assigned to your group. Using spplot() and grid.arrange(), create a multipart figure that consists of four maps: marz-level yield, production amount, sown area and harvested area of your crop averaged for the period 2005 to 2015. Export your map as PNG.

Part B: Phenological observations

Exercise 06 (10 points)

Import the file with the phenological observations that corresponds to the crop assigned to your group from the folder “phenology_by_crop”. You find the list of crops for each group in the file “M01_Overview.pptx”. Using the functions group_by() and summarize(), calculate the earliest starting date of each phenological phase of the crop assigned to you, for each possible combination of year and variety.

Exercise 07 (10 points)

Using ggplot(), create a figure of the DOYs of the harvest dates, with one box plot for each variety. Export your plot as PNG.

Exercise 08 (10 points)

Create a subsample of your data that contains observations of all phenological phases from 2000 onwards. Use ggplot() to create a facetted figure that shows the DOYs of the phenological observations on the y-axis. Each facet should represent one agrometeorological station, and each facet should contain one box plot for each phenological phase. Export your plot as PNG.

Part C: Maps of yield statistics with ggplot()

Exercise 09 (10 points)

Import the table “all_stats.csv” and select the entries corresponding to the crop you analyzed in exercises 01 to 05. Use ggplot() to create a marz-level map of the 2020 sown area. Export your map as PNG.

Exercise 10 (10 points)

Import the table “all_stats.csv” and select the entries corresponding to the crop you analyzed in exercises 01 to 05. Use ggplot() to create a facetted figure with 6 maps. These maps should represent the mean sown area, production and yield across two time periods: 2005 to 2012, and 2013 to 2020. Arrange the 6 maps using the function facet_grid() (not facet_wrap()!). Export your map as PNG.