Skip to content

Instantly share code, notes, and snippets.

@georgestagg
Created April 28, 2026 14:33
Show Gist options
  • Select an option

  • Save georgestagg/5af1eaf88e7a555020fbb8fb51c6b7b5 to your computer and use it in GitHub Desktop.

Select an option

Save georgestagg/5af1eaf88e7a555020fbb8fb51c6b7b5 to your computer and use it in GitHub Desktop.
ggsql visualisation for #TidyTuesday 2026 W17
SELECT DISTINCT
CAST(FLOOR(YEAR(t.begin_effective_date) / 5) * 5 AS INTEGER) AS period,
s.section,
t.hts8,
t.agreement,
t.ad_val_rate * 100 AS rate
FROM read_csv('2026-W17/tariff_agricultural.csv', nullstr='NA') t
JOIN read_csv('2026-W17/hts_sections.csv') s
ON LEFT(t.hts8, 2) = s.chapter
WHERE t.ad_val_rate > 0 AND t.ad_val_rate < 1
AND YEAR(t.begin_effective_date) >= 1995
VISUALISE period AS x, rate AS y, section AS fill
DRAW boxplot
SETTING outliers => false
PLACE text
SETTING
x => 2015,
y => 74,
label => 'Around 2015, high initial rates from\nDR-CAFTA, Korea, Colombia & Peru FTAs\nall overlap before declining',
hjust => 'right',
offset => (-12, 0)
SCALE ORDINAL x
RENAMING 1995 => '1995-99', 2000 => '2000-04', 2005 => '2005-09', 2010 => '2010-14', 2015 => '2015-19', 2020 => '2020-24'
SCALE y FROM (null, 85)
LABEL
title => 'Distribution of US Agricultural Tariff Rates',
subtitle => 'Rates at time of introduction, by 5-year period and HTS product section\nSource: USITC Tariff Database',
y => 'Ad valorem rate (%)',
x => null,
fill => null
@georgestagg

Copy link
Copy Markdown
Author
visualisation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment