Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggsave isntead of pdf in writing data #121

Closed
sstevens2 opened this issue Jun 18, 2022 · 5 comments · Fixed by #148
Closed

ggsave isntead of pdf in writing data #121

sstevens2 opened this issue Jun 18, 2022 · 5 comments · Fixed by #148

Comments

@sstevens2
Copy link
Contributor

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.

@albhasan
Copy link
Contributor

albhasan commented Nov 3, 2023

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.

@mikemahoney218
Copy link
Member

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.

@albhasan
Copy link
Contributor

albhasan commented Nov 3, 2023

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.

@mikemahoney218
Copy link
Member

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!

@albhasan
Copy link
Contributor

albhasan commented Nov 3, 2023

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.

albhasan added a commit to albhasan/r-intro-geospatial that referenced this issue Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants