First line of every R script?

It does, as long as you're not sharing that script! Bad behavior to start by clobbering someone's workspace! @jennybryan had a good post/tweet/something about this, I think.

If you're using RStudio, there's a cleaner solution. Go to Tools | Global Options | General and untick one box and change a dropdown:
image
This way you get the same behavior as rm(list=ls()) but your scripts will play well when shared with others.
I didn't figure this out on my own but I can't remember where I heard it suggested as a good practice. Probably on twitter.

6 Likes