One common reason why your graph may not be displaying is that you may have not typed the name of your graph and run it.
There are a two common reasons why R might not be able to find your variable. Check that you have spelt the name exactly as it appears in the dataset (remember that you can use the codebook to check variable names and descriptions to do this)
Another possiblity is that you may have not used the $
to explicitly state which variable you would like R to find.
Once you plot your graph in the bottom right panel of R studio you can use the ggsave() function to save your most recent plot. Your code should look something like
library(ggplot2)
ggsave("the_name_of_your_plot")
Whenever you use the ggsave()
function, your plot will be saved in your working directory. If you are not sure what your working directory is use the getwd()
function.
Check if you have called ggplot from your library using the function library(ggplot2)
.