nDat <- data.frame(yr=2000:2015,
Y=0:15)
rDat <- data.frame(Yr=2018:2011,
y=c(17:13, 13:11))
nrDat <- compareOverlap(
newDat=nDat, refDat=rDat)
# Correct answer
NRdat <- data.frame(yr=2011:2015,
YNew=11:15, yRef=c(11:13, 13:14),
dy=c(0,0,0, 1, 1),
dyRef=c(0,0,0, 1,1) /
c(11:13, 13:14))
stopifnot(
all.equal(nrDat, NRdat)
)
Run the code above in your browser using DataLab