rstudio::conf(2022)
Building Production-Quality Shiny Applications
Eric Nantz
{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)
readr::read_csv("path/to/file.csv")
openxlsx::write.xlsx(df, file = "/path/to/file.xlsx")
Behind the scenes: connections are dynamically created (and terminated) during file input/output.
{dplyr}
Skillz{dbplyr}
provides automatic translation from dplyr syntax to SQL statements
{DBI}
{dplyr}
Skillzlibrary(dplyr)
sample_db <- tbl(con, "sample_data")
sample_db %>%
group_by(department) %>%
summarize(total_objects = sum(n_objects, na.rm = TRUE))
# Source: lazy query [?? x 2]
# Database: sqlite 3.39.1 [:memory:]
department total_objects
<chr> <int>
1 Ancient Near Eastern Art 116
2 Arms and Armor 68
3 Arts of Africa, Oceania, and the Americas 88
4 Asian Art 32
5 Costume Institute 104
6 Drawings and Prints 60
7 Egyptian Art 128
8 European Sculpture and Decorative Arts 360
9 Greek and Roman Art 424
10 Islamic Art 164
# … with more rows
In the application ex-1/app.R
, pivot the backend to leverage a SQLite database. See the Exercise 1 page for additional details.
10:00
Logical ways to manage connections when developing solo
{pool}
!Abstraction layer on top of database connection objects
Application Programming Interface: Method of communicating between different software services
{httr2}
A ground-up rewrite of
{httr}
providing a pipeable API
Code-Along 1: Calling the MET Museum API using {httr2}
Call the MET Museum API and a custom image overlay API within the Shiny app. See the Exercise 3 page for additional details.
10:00
{DBI}
: R Database Interface{dbplyr}
: A {dplyr}
backend for databases{dm}
: Relational data models{plumber}
: An API generator for R