Let’s learn to start projects in RStudio - an important step to a good workflow in R.
I created n number of files while I started working with R at the beginning. I worked on multiple projects all of which accumulated in the same folder. I learnt about a good workflow only later and I believe it is important to be organized from the beginning of learning R.
Enter an important step in reproducible research: Working within projects. Learning to work within projects even at the beginning lets you be organized by maintaining the analyses files in a legible way. This prevents you from drowning into n^n files you would otherwise accumulate. Also, this makes your analyses reproducible and hence makes this a crucial step to Open Science workflow.
First, create a folder in your system where you would store all the R projects. Remember exactly where create this.
Open R studio, and go to
File –> New project
Another way of opening a new project is clicking on the current project you are working on when RStudio is open. You can find what project you are currently working at the right top corner of the environment pane.
You can create new project from here as well.
Either way (step 1a/1b) opens the following window
Click new directory and select new project.
Give a name related to your data analysis as a new project name and remember to select the folder you created in step 1 from the browse button under create project as a subdirectory of
.
This creates the new project you just created inside the R project folder you created at the prerequisite step.
I will brief on two other ways you can create projects and related folders; these come in handy when you don’t know how to organize but you need to be.
library(ProjectTemplate)
#create.project(project.name = "trial project")
I have added a comment tag (# symbol) here to avoid creating a project folder in this library, I only want to demonstrate, not create, hence the tag, you might want to drop the # symbol to create the folder. Also you can name the project whatever you want.
While writing this I came across another package, library(starter)
which helps you create project subfolders. Here you would use create_project()
, note the underscore between create and project, unlike create.project()
in ProjectTemplate
library.
For more information on this package read here.
So, create an R project for every data analysis you work on. Maintain your analysis scripts, data and also the plots here at one place. When reviewer 2 asks for any additional analyses, be confident and pull the files in style.
Happy organizing until I see you tomorrow with another post!
For attribution, please cite this work as
Soundararajan (2021, Aug. 4). My R Space: Starting Projects in RStudio. Retrieved from https://github.com/soundarya24/SoundBlog/posts/2021-08-03-starting-projects-in-rstudio/
BibTeX citation
@misc{soundararajan2021starting, author = {Soundararajan, Soundarya}, title = {My R Space: Starting Projects in RStudio}, url = {https://github.com/soundarya24/SoundBlog/posts/2021-08-03-starting-projects-in-rstudio/}, year = {2021} }