inst/how_to_guide/README.md

A framework for project structure with R

Build-up well-conceived R-projects without a time lag.

Using R and RStudio facilitates the process of initializing R-projects to structure your work. However it is advisable to standardize your workflow in order to write well organized code that can be passed on to others and try to include standards of reproducibility. The R-package framework gives you the opportunity to initialize a well-conceived project structure with only one line of R-code:

framework::project_framework("path/2/your/new/project")

Features of a framework-project

Structure of a framework-project

Almost every researcher/statistician (...) has its own workflow. At least there are many different demands people prefer to work with. Anyhow the setup plays a very important role when working on projects. Therefore the directory structure of framework projects are fully customizable from the start. All you have to do is to pass different arguments when invoking the function 'project_framework'. It is even possible to copy a local template of a makefile by using this function.

However per default the following directory structure will be implemented:

* This directory further includes additional files and subdirectories: e.g. an Rproj-file, packrat-repo, git-repo, git-ignore, a hidden cache-directory, a backup-directory, a how-to-manual, a README.md and a current session info. ** These directories should be treated as read only because they will be deleted and rebuilt every time you source the file make.R

More information on the structure of framework-projects

The functional principle of framework-projects is inspired by the software GNU Make. Basically a project consists of several processing steps. Ideally these steps are written separately into different files (which will hereinafter be referred to as 'source-files'). An additional makefile (or in the case of a framework-project a make-like file make.R) contains all information and instructions to process and combine the source-files. In other words: By calling the make-like file make.R the whole framework-project will be processed. Additionally you will always be able to keep track of your processing steps by reading the file make.R. If your source-files as well as the order of your processing steps do not change it is not necessary to process them. Therefore a framework-project makes use of a cache-directory per default (nonetheless optionally for each source-file). Thanks to this feature the processing speed of a framework-project is very fast. Furthermore the output of a framework-project is always up-to-date and you will be able to detect and locate bugs at an early stage.

Choose your favourite IDE

Although the package includes addins for RStudio you can use ANY Text-Editor. It is even straightforward to work on your project from the command line (using Text-Editors like nano or vim and process your whole project by running RScript make.R). If your Text-Editor supports custom keybindings for shell scripts (e.g. the GNOME text editor 'Gedit') you can write a simple shell script (see command above) and process your whole project with a simple shortcut. If you are using RStudio you simply need to specify a custom keybinding for the addin Execute source('make.R').

A Metaphor on how to use a framework-project

Writing a book is similar to writing an R-project.

Installation of the R-package framework

Required Software

Recommended Software

Installation

devtools::install_github("sachserf/framework")

Initialize a framework-project

Usage of a framework-project

*** There are several ways to source the makefile:

  1. open the R-console and type source("make.R") (Or use the Addin insert source make R)

  2. open the file make.R and hit the source-button (upper-right corner of the source-pane in RStudio)

  3. Use a keybinding for the Addin source make R to source the file make.R automatically (To enable this feature you will need to specify a custom keybinding within RStudio: Tools --> Modify Keyboard Shortcuts...)

  4. Start a terminal in your project directory and use the command RScript make.R

Further Good behaviour when working on framework-projects

NOT-TO-DO-LIST when working on framework-projects

Further information



sachserf/repres documentation built on May 29, 2019, 12:21 p.m.