Working within R projects

It is strongly encouraged to organize your work within a self-contained R project. An R project is a way to store all files related to one project in one place (R scripts, source files, location of the R working directory, RStudio workspace).

Read more about a project-oriented workflow in this tidyverse article: https://www.tidyverse.org/articles/2017/12/workflow-vs-script/

Opening a new R project

Select File -> New Project from the top RStudio menu.

Creating a new R project will create:

  • A new project directory (folder)
  • A R project file (.Rproj) in the project folder that serves as a shortcut to open the project via RStudio

Note:

  • You can make sub-folders for data, scripts, etc.
  • All files produced by R scripts saved to the project will also save into the project folder

Navigate and open project files, such as scripts, using the Files tab of the lower-right RStudio pane.

For an RMarkdown to produce the final report correctly, you must have read/write permissions for the location of the R project folder. On an MSF computer this is generally the c:/temp folder.

Sending an R project

One significant benefit of working within an R project is that all associated files (datasets, etc.) are located within the same folder. Thus, to send the project to someone else, simply zip the folder and send. All files referenced in the scripts are included and no file pathways in the script are unique to your computer.