R code for fitting topic models