Skip to content

Instantly share code, notes, and snippets.

@standarderror
Created April 8, 2017 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save standarderror/e439c6d34d7f09f5036aa7bdff9a798c to your computer and use it in GitHub Desktop.
Save standarderror/e439c6d34d7f09f5036aa7bdff9a798c to your computer and use it in GitHub Desktop.
SQL equivalents in R
SELECT ... FROM a JOIN b WHERE ... GROUP BY ... HAVING ... ORDER BY ...
is equivalent to a chain of R commands involving
a %>%
select(...) %>%
filter(...) %>%
inner_join(b, ...) %>%
group_by(...) %>%
summarise(...) %>%
filter(...) %>%
arrange(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment