Sitemap
DataDrivenInvestor

empowerment through data, knowledge, and expertise. Join DDI community at https://join.datadriveninvestor.com

Member-only story

Visualizing SQL Queries in R: How to Use ggsql

9 min readJun 8, 2026

--

Press enter or click to view image in full size

Most data analysts already know how to write a SELECT statement. SQL is the lingua franca of data work — dependable, composable, and nearly universal across industries. Getting that data into a visualization, though, has always required a separate step: export to R, load ggplot2, map aesthetics, add layers. That gap is small but real, and for analysts who live in SQL, it can feel like crossing a border every time a chart needs to be made.

ggsql closes that gap. Released in alpha by Posit in April 2026, ggsql is an implementation of the grammar of graphics built directly on SQL syntax. You write a query, and the visualization is part of the query. The same composable, declarative thinking that makes SQL powerful for data manipulation extends naturally into data presentation.

For R users who already rely on ggplot2 for visualization and DBI or DuckDB for database work, ggsql adds a new option: a single query syntax that handles both transformation and display, with bidirectional data flow into and out of R sessions.

--

--

#analytics |#datascience |#JS |#rstats |#marketing services for #smallbiz | #retail | #nonprofits Contrib @CMSWire @smallbiztrends #blackbusiness #BLM

DataDrivenInvestor
DataDrivenInvestor

Published in DataDrivenInvestor

empowerment through data, knowledge, and expertise. Join DDI community at https://join.datadriveninvestor.com