Created
February 15, 2022 16:04
-
-
Save AdamSpannbauer/74a3e9ba75fb82cad5d9b78d97809589 to your computer and use it in GitHub Desktop.
sqldf examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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