dplyrのmutateでlag(自分の使うところだけ)


    color <- c("R","B","B","R","R")
    weight <- c(51,55,72,57,64)
    dfrm <- data.frame(COL=color, WEI=weight)

f:id:koiti_yano:20200324003517p:plain


    dfrm %>% mutate(WEILag = lag(WEI))

f:id:koiti_yano:20200324003932p:plain

メモ:lagを使うと、データは下に1段下がる(1行下がる)。