- RStudio Introduction
- RStudio Projects
- Organize Files in RStudio
Why would you use RStudio projects? It is recommended to use projects in R Studio. It is recommended that you always close your project when you are finished working on it and open it up when you begin working on it. A project folder in RStudio is just like a regular folder in your operating system. It’s not special.
Projects keeps scripts and data in a single folder. Projects keep project files separate from other projects. Projects identify the working directory for R.
Creating a New Project
The first thing to do is decide on a folder name for your new project and a folder location. In RStudio you can create the folder ahead of time or let RStudio create it for you. Either way is fine. It’s just a matter of preference.
If you choose New Project as the Project Type (in the second dialog box – not shown here), you will be asked for the name of the folder, as shown in the screenshot below.
After you create a new project in RStudio, you will notice that the Environment is empty. In the Files tab you will notice one file with an extension of .Rproj. We never need to look at that file. It stores behind-the-scenes information. When you create a new project you will notice that the working directory is set to the new project. To test that, run getwd().
> getwd() [1] "D:/MyData/Portfolio/R/MyTestProject"
Now that you have a project under a folder, go ahead and put other files in that folder. For example, you can put data files in that folder. You’ll probably want to add a readme file.