Make sure to download the necessary packages before you try to call them from your library. On the R Studio IDE, there are several ways to do this. One is to use the bottom right window and select the tab "Packages". From there click the option "install" and search "ggplot2". A much faster and direct way is to just use the function
install.packages()
For example:
install.packages("ggplot2") should be implemented before using the function library()