Skip to content

Instantly share code, notes, and snippets.

@AdamSpannbauer
Created February 15, 2022 16:04
Show Gist options
  • Save AdamSpannbauer/74a3e9ba75fb82cad5d9b78d97809589 to your computer and use it in GitHub Desktop.
Save AdamSpannbauer/74a3e9ba75fb82cad5d9b78d97809589 to your computer and use it in GitHub Desktop.
sqldf examples
# install.packages('sqldf')
library(sqldf)
data("mtcars")
# Select all
sqldf("SELECT *
FROM mtcars")
# single column
sqldf("SELECT cyl
FROM mtcars")
# select first row of cyl column
sqldf("SELECT cyl
FROM mtcars
LIMIT 1")
# filter and sort
sqldf("SELECT *
FROM mtcars
WHERE mpg > 30
ORDER BY hp")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment