thetas R script