Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
{dplyr}
Jedi{DBI}
Unified set of methods & classes bridging interfacing R to database management systems (DBMS)
You have used connections in R (and may not realize it)
read.csv("path/to/file.csv", stringsAsFactors = FALSE)
::read_csv("path/to/file.csv")
readr
::write.xlsx(df, file = "/path/to/file.xlsx") openxlsx
Behind the scenes: connections are dynamically created (and terminated) during file input/output.
Hosted on server
Access via authentication
Ideal for production-grade DB workflows
library(DBI)
library(RSQLite)
# initialize connection object
<- dbConnect(
con drv = RSQLite::SQLite(),
dbname = ":memory:"
)
# send data frame to a table
dbWriteTable(con, "sim_patients", sim_patients)
# disconnect when done
#dbDisconnect(con)
{dplyr}
Skillz{dbplyr}
provides automatic translation from dplyr syntax to SQL statements
{DBI}
{dplyr}
Skillzlibrary(dplyr)
<- tbl(con, "sim_patients")
sim_patients_db
%>%
sim_patients_db group_by(ethnicity) %>%
count()
# Source: SQL [2 x 2]
# Database: sqlite 3.39.4 [:memory:]
ethnicity n
<chr> <int>
1 hispanic 20
2 nonhispanic 140
Logical ways to manage connections when developing solo
{pool}
!Abstraction layer on top of database connection objects
<- dbConnect(
con drv = RSQLite::SQLite(),
dbname = ":memory:"
)
<- dbPool(
pool drv = RSQLite::SQLite(),
dbname = ":memory:"
)
Optimize backend calculations in {simclindata.shiny}
with SQLite database