Improving R execution speed by profiling the script and finding the bottleneck