There's a new feature on RStudio. Just right-click on the a script's tab and choose "Set Working Directory" The script has to be saved first as an R file for this to work (see this comment)