Field note · July 15, 2024

clinical-trial.adverse_event: 4 values, 97.8% in the top three

4 values with 64.8% concentrated in one of them, and what that does to every chart downstream.

1 min read ·Visualization ·visualization practice

Distribution of adverse_event on clinical-trial, because every chart built on it inherits this shape.

  • none — 583 rows, 64.8%
  • mild — 211 rows, 23.4%
  • moderate — 86 rows, 9.6%
  • severe — 20 rows, 2.2%

The top three take 97.8% between them. With only 4 values there is no tail to worry about, which makes this a genuinely easy column to chart.

sql
select adverse_event,
       count(*)                                      as rows,
       round(100.0 * count(*) / sum(count(*)) over (), 1) as pct,
       round(avg(baseline_score)::numeric, 2)             as avg_baseline_score
from clinical_trial
group by 1
order by rows desc;

The second column is the one that matters. Share of rows tells you what is common; avg_baseline_score tells you whether the common thing is the important thing. They disagree more often than not, and a chart that shows only the first is answering the easier question.

Decide what happens to the tail before you plot it. "Other" as an explicit bucket is honest; twelve slivers is not, and neither is silently taking the top eight.