Skip to main content

Function: corsi_fenwick_on_ice()

corsi_fenwick_on_ice(pbp): Row[]

Defined in: src/analytics/hockeytech.ts:840

Player-level on-ice CF/CA/FF/FA from an ENRICHED pbp (needs event, team_id, home_team_id, on_ice_home, on_ice_away). Home-team events credit the home on-ice players "for" and the away ones "against" (and vice versa); blocked_shot counts for Corsi only. player_id is a string; rows are in first-seen order.

Parameters​

pbp​

Row[]

Enriched rows (see enrich_pbp). If the first row lacks any of the five required columns the result is []. Events with a null team_id, home_team_id, on_ice_home or on_ice_away are skipped.

Returns​

Row[]

One row per player id seen in an on-ice list: player_id (trimmed string), corsi_for, corsi_against, corsi_for_pct (null when CF + CA is 0), fenwick_for, fenwick_against, fenwick_for_pct, corsi_includes_missed (always false).

Example​

import { corsi_fenwick_on_ice } from "sportsdataverse/dist/analytics/hockeytech.js";
const players = corsi_fenwick_on_ice(enrichedPbp);
players.find((p) => p.player_id === "5121")?.corsi_for_pct;

Remarks​

player_id here is the string split out of on_ice_*; game_corsi_rows joins it to player_toi on that string.