Update on R script - now supports a few analyses