complete R file for assignment 2