Hello! I noticed that lagvar() only recognizes obs>=1 as the starting value but not 0. Some ESM researchers code the starting beep as beep=0 and this function may return NA wrongly. Would you add this requirement to the documentation, or amend the code so it can take beep=0 (or even negative values, if not an issue)?
datbeep2 <- structure(list(subject = c(rep(1,4),rep(2,4)), beep =
rep(1:4,2),
relaxed = c(1,2,3,4,5,6,7,8)),
row.names = c(NA, 8L), class = "data.frame")
datbeep1 <- structure(list(subject = c(rep(1,4),rep(2,4)), beep =
rep(1:4,2),
relaxed = c(1,2,3,4,5,6,7,8)),
row.names = c(NA, 8L), class = "data.frame")
datbeep0 <- structure(list(subject = c(rep(1,4),rep(2,4)), beep =
rep(0:3,2),
relaxed = c(1,2,3,4,5,6,7,8)),
row.names = c(NA, 8L), class = "data.frame")
datbeepm1 <- structure(list(subject = c(rep(1,4),rep(2,4)), beep =
rep(-1:2,2),
relaxed = c(1,2,3,4,5,6,7,8)),
row.names = c(NA, 8L), class = "data.frame")
datbeep1$relaxed_lag <- lagvar(relaxed, id=subject, obs=beep, data=datbeep1)
datbeep2$relaxed_lag <- lagvar(relaxed, id=subject, obs=beep, data=datbeep2)
datbeep0$relaxed_lag <- lagvar(relaxed, id=subject, obs=beep, data=datbeep0)
datbeepm1$relaxed_lag <- lagvar(relaxed, id=subject, obs=beep, data=datbeepm1)
datbeepm1
datbeep0
datbeep1
datbeep2