Update R code - Part #2

Adjust final code to correct for sorting,  Change variable from Character to number for proper numeric sorting.