final r script for course project