Skip to content

Instantly share code, notes, and snippets.

@charliejhadley
Created May 5, 2022 10:51
Show Gist options
  • Save charliejhadley/4b9736dc05982d7df392c8e7a9c97266 to your computer and use it in GitHub Desktop.
Save charliejhadley/4b9736dc05982d7df392c8e7a9c97266 to your computer and use it in GitHub Desktop.
avoid-tidyeval.R
library(tidyverse)
library(palmerpenguins)
make_penguin_scatter_avoid_tidyeval <- function(facet_variable){
penguins_tidy <- penguins %>%
select(bill_length_mm, bill_depth_mm, all_of(facet_variable)) %>%
rename_with(.cols = 3, ~"thing_to_facet_by")
penguins_tidy %>%
ggplot(aes(x = bill_length_mm,
y = bill_depth_mm)) +
geom_point() +
facet_grid(~ thing_to_facet_by)
}
make_penguin_scatter_avoid_tidyeval("island")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment