R/list_lag.R

list_lag <- function(x, p){
  list_mat <- list()
  for(i in 1:p) {
    list_mat[[i]] <- rbind(matrix(ncol = ncol(x), nrow = i), x)[1:(nrow(x)-p + 1), ]
    # colnames(list_mat[[i]]) <-  paste0(colnames(list_mat[[i]]),"_t-", i)
  }
  list_mat_comp <- na.omit(do.call(cbind,list_mat))
  return(list_mat_comp)
}

Try the gstar package in your browser

Any scripts or data that you put into this service are public.

gstar documentation built on June 28, 2019, 5:02 p.m.