Recall & Review
beginner
What is the purpose of the
ggsave() function in R?ggsave() saves a plot created with ggplot2 to a file on your computer, like a PNG or PDF.
Click to reveal answer
beginner
Which argument in
ggsave() specifies the filename and file type?The filename argument sets the name and extension (like "plot.png") to decide the file type.
Click to reveal answer
beginner
How do you save the last plot you made using
ggsave() without specifying the plot object?If you don't give a plot to ggsave(), it saves the last plot you displayed.
Click to reveal answer
intermediate
What arguments control the size of the saved plot in
ggsave()?width and height set the size of the saved image, usually in inches.
Click to reveal answer
intermediate
Can
ggsave() save plots in formats other than PNG? Name two.Yes! It can save as PDF, JPEG, TIFF, SVG, and more, depending on the file extension you use.
Click to reveal answer
What happens if you call
ggsave("myplot.pdf") without specifying a plot?✗ Incorrect
If no plot is given, ggsave() saves the last plot displayed.
Which argument do you use to change the width of the saved plot in
ggsave()?✗ Incorrect
The width argument sets the width of the saved image.
If you want to save a plot as a PNG file, what should the filename end with?
✗ Incorrect
The filename should end with .png to save as a PNG image.
Which package must be loaded to use
ggsave()?✗ Incorrect
ggsave() is part of the ggplot2 package.
What does
ggsave("plot.svg", plot = myplot) do?✗ Incorrect
This saves the plot stored in myplot as an SVG file named "plot.svg".
Explain how to save a ggplot as a PDF file with a custom width and height using
ggsave().Think about the filename and size arguments.
You got /5 concepts.
Describe what happens if you call
ggsave() without specifying a plot and how you can save a specific plot instead.Consider the default behavior and how to override it.
You got /2 concepts.