completed R file