% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Clean.R
\name{add_deltas}
\alias{add_deltas}
\title{Add event-to-event deltas to a play-by-play}
\usage{
add_deltas(play_by_play)
}
\arguments{
\item{play_by_play}{data.frame of play-by-play(s) using the current public schema returned by \code{\link[=gc_play_by_play]{gc_play_by_play()}}, \code{\link[=gc_play_by_plays]{gc_play_by_plays()}}, \code{\link[=wsc_play_by_play]{wsc_play_by_play()}}, or \code{\link[=wsc_play_by_plays]{wsc_play_by_plays()}}}
}
\value{
data.frame with one row per event (play) and added columns: \code{eventIdPrev}, \code{secondsElapsedInSequence}, \code{dSecondsElapsedInSequence}, \code{dXCoord}, \code{dYCoord}, \code{dXCoordNorm}, \code{dYCoordNorm}, \code{dDistance}, \code{dAngle}, \code{dXCoordPerSecond}, \code{dYCoordPerSecond}, \code{dXCoordNormPerSecond}, \code{dYCoordNormPerSecond}, \code{dDistancePerSecond}, \code{dAnglePerSecond}
}
\description{
\code{add_deltas()} adds event-to-event deltas in raw and normalized x/y,
distance, and angle for a play-by-play. Sequences are bounded by faceoffs:
each sequence begins at a faceoff, faceoff rows do not look backward across
the boundary, and subsequent events are compared to the most recent prior
valid-spatial event in the same faceoff-bounded sequence. Shootout and
penalty-shot rows (\code{0101}/\code{1010}) are left as \code{NA} and do not serve as
anchors for later rows. When multiple events in a sequence share the same
recorded second, zero-time denominators used internally are replaced by
\code{1 / n}, where \code{n} is the number of events in that same second within the
sequence.
}
