Changed and final R file