@andresrcs is suggesting a helpful practice--a new topic for when the question changes. In this case, as he points out, we've moved beyond installation into how to use the ggplot2
package, and people who have that question aren't likely to be looking under installation. So, please do post as a new question with a reproducible example, called a reprex .
On the other hand, while you're doing that, I'll take a guess about what may be happening.
library(ggplot2)
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point()
opens a viewer window and displays the graphical result. If you close the window, you have to run the code again. That gets tedious, so you can create an object to be able to display the graph any time. (You can also save an image to file with ggsave()
.)
library(ggplot2)
p <- ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point()
p
Created on 2019-11-24 by the reprex package (v0.3.0)