Merge pull request #28 from MarquisAlx/master

fixes #27 and #26 makes the R script more robust