Say I have a data.frame that looks like this
data.frame
df <- data.frame(AAA = rep(c(NA,sample(1:10, 1)),5), BBB = rep(c(NA,sample(1:10, 1)),5), CC
Use a combination of the very efficient transform and na.omit functions
transform
na.omit
df <- na.omit(transform(df, CCC = c(NA, CCC[-nrow(df)])))