Closed sstevens2 closed 8 months ago
You're right. Lesson 8 was written using the function pdf
and dev.off
but using ggsave
is more convenient when the plots are built using the package ggplot
, which is our case.
However, challenge 1 in lesson 8 asks the readers to save in a single file several plots in different pages; which ggsave
doesn't support currently, unless using the function marrangeGrob
from the package gridExtra
(Check Masood Sadat's answer to this question). I'm against adding the package gridExtra
to lesson 8 just for solving one challange.
I guess we could add code using ggsave
as an alternative to pdf
& dev.off
just after the challenge.
Is there a reason we need that challenge? How often is that a task people are trying to accomplish? This isn't something I am commonly trying to do; I feel like I'm either sending people multiple PNGs, or incorporating graphs into an R Markdown/Quarto document to get a single PDF.
We could maybe change the challenge to a ggsave()-based task if that's more relevant for learners.
I think challenge 1 is needed. Lesson 8 contains 2 topics, saving plots and writing CSV data, and accordingly, it has one challenge for each topic.
I'm also in favor of showing readers how to use both pdf
& dev.off
functions, because they're the traditional way of saving plots (by traditional I mean before the tidyverse) and there is a lot of code still using them.
To be clear, I'm suggesting that we keep a "saving plots" challenge, just suggesting that it changes to the more useful ggsave() topic rather than focusing on a legacy approach.
I don't know that we necessarily want to teach learners all the different ways they might approach a problem, or all the ways they might see in the wild. We only teach ggplot2 in this lesson, and we don't get into the details of base plotting, even though there's plenty of code still generating base plots. If we do keep references to the graphics device functions here, then I think we should minimize it as much as possible, and give learners challenges relating to the tools they're more likely to use instead.
That said, I feel like any changes to focus more on ggsave()
are good, and if the fastest/easiest version of that is simply adding it after the challenge then that's at least an improvement!
I see your point @mikemahoney218, I think you're right. I'm going to change both the text and the challenge to use only ggsave
.
Think we should change this to use ggsave. Typically a more common way to save ggplots and is more strightforward than using the plot device pdf save.