Creating a new project in RStudio

<< Previous post: Data analysis with R – getting started

One of the first things you should do after opening RStudio for a new project, is to specify a working directory. This is the folder where the project file is created in, and where you can save the input and output files to keep everything together. You can set the working directory in RStudio in:

Session → Set Working Directory → Choose Directory…

Pick or create a new folder where you want your data to be saved. To make sure that it is saving all your work when you quit the program, go to:

RStudio → Preferences… → “General” tab

and select “Always” or “Ask” in the dropdown menu after “Save workspace to .RData on exit”

Now go to:

File → New project… → Existing directory

and select the working directory that you just created. Now an .Rproj file is created with the same name of the working directory folder. To switch between different projects, or to make sure that you’re working in the correct project, look at the right upper corner or Rstudio’s toolbar; it should say the name of your current project. When you click on the project name, a dropdown menu will appear with the names of other projects, which allows you to toggle between them.

Next, before working with real data, we will explore the basic layout of RStudio, and explain how to install and load packages.

Next: Exploring RStudio’s basic layout & packages >>

Leave a Reply

Your email address will not be published. Required fields are marked *