R/YearOverYear.R

#taken from here: http://stackoverflow.com/questions/30678606/quarterly-year-over-year-growth-rate
YearOverYear<-function (x,periodsPerYear){
  if(NROW(x)<=periodsPerYear){
    stop("too few rows")
  }
  else{
    indexes<-1:(NROW(x)-periodsPerYear)
    return(c(rep(NA,periodsPerYear),(x[indexes+periodsPerYear]-x[indexes])/x[indexes]))
  }
}
matthewcurrier/bizler documentation built on May 21, 2019, 1 p.m.