MENU

Fun & Interesting

lead & lag R Functions of dplyr Package (2 Examples) | Next / Previous Element of Time Series Data

Statistics Globe 13,233 5 years ago
Video Not Working? Fix It Now

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

Comment