R code for analysis of repeated surveys