|
Dee Chiluiza, PhD Northeastern University Boston, Massachusetts |
| Short manual series: |
Create an R Project
Working with R means dealing with a lot of files, and without proper organization, this could get out of control very quickly.
As a recommendation, in the previous page I mentioned the creation of an R Project on your R Studio.
After installing R and R Studio, start by creating a Project.
Which are the benefits of creating an R Project?
‣ R requires a lot of packages for proper work, it will be easier to organize all your packages in one file, that way you don’t have to call them every time you work with your files.
‣ All your R Script and R Markdown files will be available under the same folder, it will be easier to organize and find them.
‣ Data sets will also be available under one folder, it will be easier to find them and to share them between R script and R Markdown files.
‣ You can also create folders for your support files (such as R files with codes you need to remember, PDF files with information, or websites links).
‣ When creating report documents in R Markdown, you can use your R Project to create a folder for the figures you use on those reports (JPG, PNG, GIF).
Get familiarized with the location of the folders on your computer. My recommendation: Start by creating folders on your “File Explorer” application.
‣ Select where in your computer you want to store your R files, for example: in your “Documents folder”.
‣ Start by creating a folder for you class, and inside that folder, create two folders: DataSets and Support Files. Later on you will create your own folders and develop your own organization style.
Here’s an example:
That’s all for now on your computer, now let’s go to your R Studio program.
R Studio Project
‣ Start your R Studio.
‣ If this is the first time starting the program, it is possible it will ask you to install some packages; if this is the case, accept it and allow some time to finish the process. The time is quite fast depending on the speed of your computer and the Internet connection.
‣ Remember not to worry about R Codes yet.
‣ Check the top-right corner of your R Studio windows, you will see the drop-down menu Project(None). Click that menu ans select “New Project”.
‣ Follow the image below:
‣ 1. On the first menu window, select “Existing Directory”.
‣ 2. On the new menu window “Create Project from Existing Directory”, select “Browse”.
‣ 3. A File Explorer window will open.
‣ 4. Search for your Project folder, e.g., MyClass_RProject. Click that folder only once and then select “Open”.
‣ 5. Once you click “Open”, you will be returned to the previous menu.
‣ 6. Finally, select: “Create Project”
‣ Do you remember the “Project (None)” drop-down menu? Look again, now it has the name of your R Project.
‣ As a practice, go to that drop-down menu and close your project selecting “Close Project”.
‣ Always remember: Close your project using this menu. It will save your working space and all your files.
‣ Close your R Studio only after you closed your R Project.
Get familiar with your File Explorer
‣ On your computer, go to the folder you created.
‣ The folder was empty when you created it, now it contains one file and one hidden folder.
‣ The file is your R Project file. It has the same name as your folder.
‣ The hidden folder is named .Rproj.user. Do not touch this folder, it contains all the information R Studio needs for your project.
‣ Double click this file to open your R Project.
Done!
You are ready to start working on your R Projects.
Disclaimer: This short series manual project is a work in progress. Until otherwise clearly stated, this material is considered to be draft version.