Using instructions and data from this link: https://people.math.carleton.ca/~davecampbell/datasets/2020/07/24/trade-data-monthly-exports-of-grains-open-canada/
"First subset the data so that you are only considering two commodities: “Barley”, “Oats”. Make sure you color the points with the type of commodity. Include in your plot one single regression line for this subset of the dataset, add a second regression line for this subset of data, but make sure you force the line to have a zero intercept."
Currently my code looks like this but error of unknown column 'total' is coming up. Not sure how to plot a regression line with a subset within data:
export_data |> group_by(year, Commodity, Destinations) |> filter(Commodity == "Barley" | Commodity == "Oats") |> summarize(total = sum(VALUE)) |> subset(Destinations == "Total exports, all destinations") |> ungroup() |> ggplot( aes(x = year, y = total, group = Commodity)) + labs(y = "total export (tonnes)") + geom_point(aes(color = Commodity)) + ggtitle("Total Barley and Oats export to all destinations") x <- export_data$year y <- export_data$total abline(lm(y ~ x, data = export_data), col = "yellow")