Simplified the R script, but there are some bugs
Greatly simplified directory structure