Skip to content
Snippets Groups Projects
lagvec.Rd 638 B
Newer Older
  • Learn to ignore specific revisions
  • % Generated by roxygen2: do not edit by hand
    % Please edit documentation in R/lagvec.R
    \name{lagvec}
    \alias{lagvec}
    \title{Lag by shifting}
    \usage{
    lagvec(x, lag)
    }
    \arguments{
    \item{x}{The vector to lag}
    
    \item{lag}{(integer) The steps to lag.}
    }
    \value{
    The shifted vector
    }
    \description{
    Lag by shifting the vecter
    }
    \details{
    A positive value of \code{lag} shifts the values to the right in the vector.
    }
    \examples{
    
    # The values are simply shifted
    # Ahead in time
    lagvec(1:10, 3)
    # Back in time
    lagvec(1:10, -3)
    # Works but returns a numric
    lagvec(as.factor(1:10), 3)
    # Works and returns a character
    lagvec(as.character(1:10), 3)
    
    }