Skip to main content

snakeAlign: rows split into the blocks .snake() draws

[
  [
    "KC",
    "LAC",
    "DEN"
  ],
  [
    "LV",
    "BUF",
    "MIA"
  ],
  [
    "NYJ",
    "NE",
    "(fill)"
  ]
]
import { STANDINGS } from "@sportsdataverse/examples/data";
import { snakeAlign } from "@sportsdataverse/sdvtables";

// Eight rows into three blocks of three; the last block is padded with fill (null unless you pass one).
snakeAlign(STANDINGS, { nCols: 3 }).map((block) => block.map((r) => r?.team ?? "(fill)"));

Tags: layout · snakeAlign · gt_snake_align · snake. All sdvtables examples.