R experts keep all the files associated with a project together — input data, R scripts, analytical results, figures. This is such a wise and common practice that RStudio has built-in support for this via projects. For example, a project can be a R package under development, or code, data and documents for a research project, or a book project (for example, Hadley use a RStudio project for the R for Data Science book at https://github.com/hadley/r4ds).
A RStudio project must contain a file with extension Rproj and can contain any files within the directory where the project file lives or its subdirectories. Typical types of files in a RStudio project include: - R Script - R Markdown, R notebook - R Presentation - Shiny Web App - Text file, C++, html, …
Hadley recommends the following for RStudio projects workflow:
Everything you need is in one place, and cleanly separated from all the other projects that you are working on.
I recommend organizing files in subdirectories by types, typically with at least these items:
Create an RStudio project for this class on your laptop, set up directory structure as recommended above, download the bike counts data file and save them in the data directory of your RStudio project. Create a new R script from the File menu and save it as load_data.R
into your code directory; we will populate it with R code that loads data in the next lesson.