Refactored step 3 to recode the activity column as a factor rather than use a join.
Ignoring a tmp file.