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

Evolve facets from traditional tilde notation to vars() #87

Open
arencambre opened this issue Mar 2, 2021 · 1 comment
Open

Evolve facets from traditional tilde notation to vars() #87

arencambre opened this issue Mar 2, 2021 · 1 comment

Comments

@arencambre
Copy link

Per the facet_wrap() documentation, the tilde notation in the facets argument is for "compatibility with the classic interface". It appears vars() should be used instead.

There are a few places in this book where facet_wrap() uses the tilde. It may be best to convert to vars().

For example, near the end of chapter 1 is this code example:

ggplot(frequency, aes(x = proportion, y = `Jane Austen`,
                      color = abs(`Jane Austen` - proportion))) +
  geom_abline(color = "gray40", lty = 2) +
  geom_jitter(alpha = 0.1, size = 2.5, width = 0.3, height = 0.3) +
  geom_text(aes(label = word), check_overlap = TRUE, vjust = 1.5) +
  scale_x_log10(labels = percent_format()) +
  scale_y_log10(labels = percent_format()) +
  scale_color_gradient(limits = c(0, 0.001),
                       low = "darkslategray4", high = "gray75") +
  facet_wrap(~author, ncol = 2) +
  theme(legend.position="none") +
  labs(y = "Jane Austen", x = NULL)

The facet_wrap() function call may be changed to facet_wrap(vars(author), ncol = 2).

In chapter 2 is this code example:

ggplot(jane_austen_sentiment, aes(index, sentiment, fill = book)) +
  geom_col(show.legend = FALSE) +
  facet_wrap(~book, ncol = 2, scales = "free_x")

The facet_wrap() function call may be changed to facet_wrap(vars(book), ncol = 2, scales = "free_x").

@dev881B
Copy link

dev881B commented Sep 16, 2022

Yes 👍 X

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

No branches or pull requests

2 participants