Completed R file