To be able to replicate this you need to install the ggplot2 package. Just google it and it'll be the first thing you find.
The first graph is just for show, it's basically what you present all nice and tidy. You can learn how to do it and more on "Cookbook for R" it's a very useful website, I recommend you check it out.
I tried to make the Linar Regrassion part as similiar as I could to Prof. P. Burrowes' "how to" spread sheets.