After you install R on your own machine, I would give some thought to how you want to organize your data, code, documentation, and so on. There will probably be many different kinds of projects that you will need to set up, ranging from exploratory analysis to full production-grade implementations. However, most projects will be somewhere in the middle, that is, those projects that ask a specific question or a series of related questions. Whatever their purpose, each project you will work on will deserve its own project folder or directory.
Some important points to remember about constructing projects:
- It is never a good idea to boil the ocean, or try to answer too many questions at once. Remember, predictive analytics is an iterative process.
- Another trap that people fall into is not having their project reproducible. Nothing is worse than to develop some analytics on a set of data, and then backtrack, and oops! different results.
- When organizing code, try to write code as building block, which can be reusable. For R, write code liberally as functions.
- Assume that anything concerning requirements, data, and outputs will change, and be prepared.
- Considering the dynamic nature of the R language. Changes in versions, and packages could all change your analysis in various ways, so it is important to keep code and data in sync, by using separate folders for the different levels of code, data, and so on or by using version management packages such as
subversion
,git
, orcvs
.
Once you have considered all of the preceding points, physically set up your folder environment.
We will start by creating folders for our environment. Often projects start with three subfolders which roughly correspond to:
- Data source
- Code-generated outputs
- The code itself (in this case, R)
There may be more in certain cases, but lets keep it simple:
- First, decide where you will be housing your projects. Then create a sub-directory and name it
PracticalPredictiveAnalytics
. For this example, we will create the directory under Windows drive C. - Create three subdirectories under this project:
Data
,Outputs
, andR
:- The
R
directory will hold all of our data prep code, algorithms, and so on. - The
Data
directory will contain our raw data sources that will typically be read in by our programs. - The
Outputs
directory will contain anything generated by the code. That can include plots, tables, listings, and output from the log.
- The
Here is an example of how the structure will look after you have created the folders: