Skip to content

Commit

Permalink
Merge pull request #22 from nhs-r-community/ggsave-ggplot
Browse files Browse the repository at this point in the history
Ggsave ggplot
  • Loading branch information
Lextuga007 authored Aug 25, 2023
2 parents 32f3f29 + 733b2c0 commit 8c86e3e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Empty file removed about.qmd
Empty file.
24 changes: 21 additions & 3 deletions data-visualize.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -378,18 +378,36 @@ ggplot(penguins, aes(x = species, fill = island)) +
Why?

```{r}
#| eval: false
ggplot(mpg, aes(x = class)) +
geom_bar()
ggplot(mpg, aes(x = cty, y = hwy)) +
geom_point()
ggsave("mpg-plot.png")
```

The second code is saved because it was the last code run.

2.
>What do you need to change in the code above to save the plot as a PDF instead of a PNG?
> What do you need to change in the code above to save the plot as a PDF instead of a PNG?
How could you find out what types of image files would work in `ggsave()`?

To save as a pdf the code needs to be changed from `.png` to `.pdf`:

## [2.6.1](https://r4ds.hadley.nz/data-visualize.html#exercises-3) {.unnumbered}
```{r}
#| eval: false
ggsave("mpg-plot.pdf")
```

## [2.7](https://r4ds.hadley.nz/data-visualize#common-problems) {.unnumbered}

::: {.callout-note}
There are no exercises in this section.
:::

## [2.8](https://r4ds.hadley.nz/data-visualize#summary)

::: {.callout-note}
There are no exercises in this section.
:::

1.
2 changes: 1 addition & 1 deletion index.qmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# About this book
# About this book {.unnumbered}

This unofficial book is inspired by the [R for Data Science Exercise Solutions](https://jrnold.github.io/r4ds-exercise-solutions/) and is an updated version in line with the second edition release of [R for Data Science](https://r4ds.hadley.nz/), also referred to in the short form as R4DS, by Hadley Wickham, Mine Çetinkaya-Rundel, and Garrett Grolemund.

Expand Down

0 comments on commit 8c86e3e

Please sign in to comment.