Task 1: Reflection

For this visualization, I decided to look into how the amount of water used through specific irrigation methods affects the yield of certain crops. Now obviously this is not the only aspect that affects the yield of the crop, so we have to look at this objectively rather than the end all be all visualization. After creating the visualization, it’s clear that the amount of water (as well as the method of irrigation) does not have any effect on the yield as there are several cases where the same crop has far more yield with similar amounts of water and the same method of irrigation. This could be due to outside factor such as the type of soil, amount of land used, pesticides used and even the season that they were harvested.

Task 2: Interactive plots

library(tidyverse)
library(plotly)

farming <- read_csv('agriculture_dataset.csv')

Do the following:

  1. Make a plot. Any kind of plot will do (though it might be easiest to work with geom_point()).

  2. Make the plot interactive with ggplotly().

  3. Make sure the hovering tooltip is more informative than the default.

Good luck and have fun!

farming_plot <- ggplot(
  data = farming,
  mapping = aes(x = `Water_Usage(cubic meters)`, y = `Yield(tons)`, 
                color = Irrigation_Type)) +
  geom_point(aes(text = Crop_Type)) + 
  scale_y_continuous(breaks = seq(0, 50, by =10)) + 
  scale_x_continuous(breaks = seq(0, 100000, 10000)) +
  theme_bw() # Step 1
## Warning in geom_point(aes(text = Crop_Type)): Ignoring unknown aesthetics: text
  interactive_plot <- ggplotly( # Step 2
  farming_plot, tooltip = "text" # Step 3
)
  
interactive_plot

Task 3:

Install the {flexdashboard} package and create a new R Markdown file in your project by going to File > New File… > R Markdown… > From Template > Flexdashboard.

Using the documentation for {flexdashboard} online, create a basic dashboard that shows a plot (static or interactive) in at least three chart areas. Play with the layout if you’re feeling brave.