% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lag_lead.R
\name{lead_dt}
\alias{lead_dt}
\alias{lag_dt}
\title{Fast lead/lag for vectors}
\usage{
lead_dt(x, n = 1L, fill = NA)

lag_dt(x, n = 1L, fill = NA)
}
\arguments{
\item{x}{A vector}

\item{n}{a positive integer of length 1,
giving the number of positions to lead or lag by. Default uses 1}

\item{fill}{Value to use for padding when the window goes beyond the input length.
Default uses \code{NA}}
}
\value{
A vector
}
\description{
Find the "next" or "previous" values in a vector.
It has wrapped \pkg{data.table}'s \code{shift} function.
}
\examples{
lead_dt(1:5)
lag_dt(1:5)
lead_dt(1:5,2)
lead_dt(1:5,n = 2,fill = 0)
}
\seealso{
\code{\link[dplyr]{lead}},\code{\link[data.table]{shift}}
}
