Here is my intuitive solution:
Here invshift , the number of lines minus 1, is 4. nrow(df) gives you the number of lines in the data frame or in the vector. Similarly, if you want to accept even earlier values, subtract 2, 3, ..., etc. from nrow, and put NA, respectively, at the beginning.
Abdullah Adil Mahmud Jul 05 '18 at 10:51 2018-07-05 10:51
source share