Final r script.