RStudio's Jenny Bryan (whose recent interviews here and here you should definitely check out) has some excellent advice for improving your workflow for R:
Use. Projects. — @JennyBryan at #EARLConf2017 #rstats pic.twitter.com/r4a08JhWHT
— David Smith (@revodavid) September 13, 2017
If you're you're routinely using setwd
to manually change R's working directory, or using rm(list = ls())
to 'reset' your R session, that's a good sign that you're doing all of your R work in the default R workspace. It's a much better idea to set up a separate project (at its simplest, a separate directory) for each distinct piece of work. The default R interface makes this a bit tricky, but IDEs like RStudio and RTVS are designed to make this trivial, and you'll notice an immediate impact in the organization and reproducibility of your work.
And, you won't incur the Wrath of Jenny. Find her complete guide, chock-full with useful advice, at the link below.
Tidyverse: Project-oriented workflow