# Create fake data frame
A <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2)
B <- c(1:10)
Data <- data.frame(A, B)
# Find percentage change from two periods before
Out <- PercChange(Data, Var = 'B', GroupVar = NULL,
type = 'proportion', NewVar = 'PercentChange', slideBy = -2)
OutRun the code above in your browser using DataLab