title: What's the opposite function to lag for an R vector/dataframe?
body: <p>I have a problem dealing with time series in R. </p>
  
  <pre><code>#--------------read data
  
  wb = loadWorkbook("Countries_Europe_Prices.xlsx") 
  df = readWorksheet(wb, sheet="Sheet2")
  
  x &lt;- df$Year
  y &lt;- df$Index1
  
  y &lt;- lag(y, 1, na.pad = TRUE)
  cbind(x, y)
  </code></pre>
  
  <p>It gives me the following output:</p>
  
  <pre><code>        x     y
   [1,] 1974    NA
   [2,] 1975  50.8
   [3,] 1976  51.9
   [4,] 1977  54.8
   [5,] 1978  58.8
   [6,] 1979  64.0
   [7,] 1980  68.8
   [8,] 1981  73.6
   [9,] 1982  74.3
  [10,] 1983  74.5
  [11,] 1984  72.9
  [12,] 1985  72.1
  [13,] 1986  72.3
  [14,] 1987  71.7
  [15,] 1988  72.9
  [16,] 1989  75.3
  [17,] 1990  81.2
  [18,] 1991  84.3
  [19,] 1992  87.2
  [20,] 1993  90.1
  </code></pre>
  
  <p>But I want the first value in y to be 50.8 and so forth. In other words, I want to get a negative lag. I don't get it, how can I do it?</p>
  
  <p>My problem is very similar to this problem, but however I cannot solve it. I guess I still do not understand the solution(s)...</p>
  
  <p><a href="https://stackoverflow.com/questions/3558988/basic-lag-in-r-vector-dataframe">Basic lag in R vector/dataframe</a></p>