R solutions to project2