Thesis R Code