fixed latex document structure
re-indented R code for better PDF output