elections R code