ggsql

Featured

Write ggsql queries — a grammar of graphics for SQL. Use when the user wants to create, modify, or understand a ggsql visualization query.

API & Backend 522 stars 53 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
91
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# ggsql Query Writer ggsql combines a SQL query with a Grammar-of-Graphics visualization spec in one syntax. Write queries using ONLY the syntax below — NEVER invent clauses, settings, aesthetics, layer types, or palette names; say so if unsure whether something exists. ## Query structure Optional SQL part + required `VISUALISE`/`VISUALIZE` part. - **SELECT → VISUALISE**: last statement is a SELECT (bare, `WITH...SELECT`, set ops); its result feeds VISUALISE, which has no `FROM`. ```ggsql SELECT name, score_a, score_b FROM 'dataset.csv' WHERE value > 50 VISUALISE score_a AS x, score_b AS y [DRAW / PLACE / SCALE / FACET / PROJECT / LABEL clauses] ``` - **VISUALISE FROM**: VISUALISE supplies its own source (table/file/CTE/built-in), no trailing SELECT. ```ggsql WITH summary AS (SELECT category, COUNT(*) AS n FROM 'dataset.csv' GROUP BY category) VISUALISE category AS x, n AS y FROM summary DRAW bar ``` **Data sources** (in `VISUALISE ... FROM` or `DRAW ... MAPPING ... FROM`): unquoted table/CTE (`FROM sales`), quoted file path (`FROM 'data.csv'`), built-in dataset (`FROM ggsql:penguins`, `FROM ggsql:airquality`). ## VISUALISE clause Starts the viz; optional global mappings inherited by every layer. ``` VISUALISE <mapping>, ... FROM <data-source> ``` Mapping forms: explicit `column AS aesthetic` (e.g. `revenue AS y`); implicit `column` (name = aesthetic name); wildcard `*` (all matching columns); constant `'red' AS fill`. ```ggsql VISUALISE bill_len AS...

Details

Author
posit-dev
Repository
posit-dev/skills
Created
10 months ago
Last Updated
1 weeks ago
Language
R
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category