knitr::opts_chunk$set( message = FALSE, warning = FALSE, collapse = TRUE, comment = "#>", fig.path = "README-" )
The goal of sql.helper is to help building SQL queries in R
# install.packages('devtools') devtools::install_github("taekyunk/sql.helper")
paren()
This is a basic example of using paren()
with SQL IN operator.
id_char <- as.character(1:5) id_num <- 3:8 # paren() will add single quotes if the field is not numeric paren(id_char) paren(id_num) # to match character with numeric paren(as.numeric(id_char)) # to match numeric with character paren(as.character(id_num)) # typical use case will be something like this query <- paste("select * from tablename where id in", paren(id_num), ";") print(query)
count_from()
count_from()
can be used to build SQL query to count the combination of variables.
library(tidyverse) c("x", "y") %>% count_from("schema.table")
count_rows()
count_rows()
builds SQL query to count the number of observations in a table
count_rows("schema.table")
add_limit()
add_limit(n)
adds limit condition at the end of the given SQL query
"select * from schema.table;" %>% add_limit(100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.