Skip to content

Instantly share code, notes, and snippets.

View statsmaths's full-sized avatar

Taylor Arnold statsmaths

View GitHub Profile
@kaneplusplus
kaneplusplus / tmp-tbl.r
Last active June 13, 2022 14:25
`tmp_tbl()` create a database-backed tbl that gets dropped when the handle goes out of scope
library(dplyr)
library(dbplyr)
library(uuid)
tmp_tbl <- function(x, con, tbl_name = UUIDgenerate()) {
uuid <- UUIDgenerate()
db_copy_to(con, tbl_name, as.data.frame(x), temporary = TRUE)
ret <- tbl(con, tbl_name)
ret$info <- new.env()
ret$info$con <- con