Check out example codes for "ggplot: boxplot with trendline". It will help you in understanding the concepts better.

Code Example 1

ggplot(iris, aes(factor(Sepal.Length), Sepal.Width)) +
  geom_boxplot() +
  geom_smooth(method = "lm", se=FALSE, color="black", aes(group=1))

Learn ReactJs, React Native from akashmittal.com