How to apply the lead and lag functions of the dplyr package in the R programming language. More details: https://statisticsglobe.com/r-lead-lag-functions-dplyr-package
R programming code:
x <- 1:10 # Example vector
install.packages("dplyr") # Install dplyr
library("dplyr") # Load dplyr
lead(x) # Basic application of lead
lag(x) # Basic application of lag
lead(x, 3) # Apply lead function with larger n
lag(x, 3) # Apply lag function with larger n