I'm starting to use RStudio and I found the option of creating Projects, which enables you "to divide your work into multiple contexts, each with their own working directory, workspace, history, and source documents" according to rstudio.com.
Are projects only used for package development? If not, can you show me any other typical situation where the features written above would allow you things (besides version control) impossible (or more difficult) to do in a normal workspace?
But the main advantage of projects is that they make your life easier when importing data. If you've used R before, you'll be familiar with the concept of a working directory. If not, then a working directory is simply the place where R is currently looking for files.
An R project enables your work to be bundled in a portable, self-contained folder. Within the project, all the relevant scripts, data files, figures/outputs, and history are stored in sub-folders and importantly - the working directory is the project's root folder.
If you're using RStudio, you have the option of creating a new R project. A project is simply a working directory designated with a . RProj file.
Projects are convenient in several ways.
You have mentioned version control. Even if you work alone, it is useful, and it can also be used for text files, e.g. if you use markdown/knitr/Sweave combos (see Reproducible Research). I use Git with Dropbox to track my progress both for code and reports.
Each project has its own working directory. You can achieve that in bare R, but R studio manages this automatically.
The same goes for your workspace, each project has a separate one.
Source files you had open in re-loaded project will open automatically.
Basically, projects are useful if you have to work with, well, multiple projects. You switch between them quickly and you get the same workspace, working directory, which means loaded objects and history. As if you have never switched. It is not impossible to do this without projects, but it is much less convenient, which was your question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With