Skip to main content

NFL EPA per play: all 32 teams, paged and sortable, with colour pills, a delta and a legend

NFL 2024
Who moved the ball, and who stopped itExpected points added per rush or pass play, regular season
Net
Baltimore Ravens0.1970.018▲ 0.215
Buffalo Bills0.1870.003▲ 0.190
Detroit Lions0.1550.045▲ 0.200
Washington Commanders0.139-0.043▲ 0.096
Tampa Bay Buccaneers0.132-0.017▲ 0.115
Philadelphia Eagles0.1110.086▲ 0.196
Cincinnati Bengals0.106-0.055▲ 0.052
Green Bay Packers0.0800.068▲ 0.148
Source: nflverse play_by_play_2024
EPA per play
-0.250.25
import { NFL_TEAM_EPA_2024 } from "@sportsdataverse/examples/data";
import { createTable, defineTable } from "@sportsdataverse/sdvtables";
import { hydrate, prepare, renderHTML } from "@sportsdataverse/sdvtables/html";

// EPA per play from the season totals. A defence's EPA allowed is flipped in sign (EPA saved), so higher is better in
// both pill columns and one legend reads for both; net = offence minus EPA allowed.
const rows = NFL_TEAM_EPA_2024.map((r) => ({
logo: r.team,
team: r.team,
off: r.off_epa / r.off_plays,
saved: -r.def_epa / r.def_plays,
// delta(from, to) shows to - from under the key `from`, so the net column reads EPA allowed under its own key
net: r.def_epa / r.def_plays,
}));
const spec = defineTable<(typeof rows)[number]>()
.columns((c) => [
c.logo("logo", { league: "nfl", label: "", sortable: false }),
c.wordmark("team", { league: "nfl", label: "Team", filterable: true }),
c.colorPills("off", { label: "Offence", digits: 3, domain: [-0.25, 0.25] }),
c.colorPills("saved", { label: "Defence", digits: 3, domain: [-0.25, 0.25] }),
c.delta("net", "off", { label: "Net", decimals: 3, arrows: true, sortable: false }), // its key holds EPA allowed, so sorting it would sort by defence
])
.legendContinuous({ title: "EPA per play", digits: 2 })
.titleHeader("Who moved the ball, and who stopped it", {
kicker: "NFL 2024",
subtitle: "Expected points added per rush or pass play, regular season",
})
.sourceNote("Source: nflverse play_by_play_2024")
.theme("sdv")
.rowKey("team")
.build();
await prepare(spec);
// eight teams a page, the best offence first; sort any column, filter by team
const table = createTable(spec, rows, { pageSize: 8, sort: { col: "off", dir: "desc" } });
const host = document.createElement("div");
host.innerHTML = renderHTML(table);
hydrate(host.querySelector(".sdvt") as Element, table);
host;

Tags: table · recipe · interactive · logo · wordmark · colorPills · delta · legendContinuous · nfl. All sdvtables examples.