Modified Perl script and added R script