R code for analysis of a single survey