'How can I make a plot of the yield of sugarcane, coconut and rice in time

df <- out
yield_calc <- function(production,area){
  yield = production/area
  print(yield)
}

df <- df %>%
  mutate(Yield = Production/Area)

library(ggplot2)
yield_data <- data.frame(Year = df$Year, Yield = df$Production/df$Area, Crop = df$Crop )
yield_data <- yield_data %>%
  filter (Crop =="Rice" | Crop == "Sugarcane" | Crop == "Coconut")

yield_data %>%
  ggplot(aes(Year,Yield, color = Crop))+
  geom_smooth()+
  ylab("kg/ha")

https://www.kaggle.com/datasets/chinmaynagesh/crop-yield-per-state-and-rainfall-data-of-india This is the data which I am using. how can I make a Plot the yield of sugarcane, coconut and rice in time.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source