Skip to content

A minimal data analysis project in R, using GNU make, R Markdown, and unit tests

License

Notifications You must be signed in to change notification settings

murattasdemir/minimal-r-project-with-make

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A minimal R project with make

This is a minimal R project (e.g. the starting point for a new analysis, study or report) which uses GNU make to automatically test R code (with package testthat) and generate an HTML report (with R Markdown).

The easiest way to get to grips with this project is to clone the repository to your local UNIX-like environment, and run make.

This project was motivated by blog posts by Karl Broman and Jon Zelner about using make and Makefiles with R, with additional inspiration to incorporate dummy tests from the r-lcfd repository by Steven Loria.

More in-depth examples of using make and Makefiles with R can be found via the blog posts linked above, and the example-r-analysis repository, by Konrad Rudolph.

Basic usage

The intended use of this project is as template for a non-trivial analysis. If you have a GitHub account, please fork this repository first. Then to get started on any UNIX-based system, simply clone to a new local repository named new-project (or whatever you want to call it):

git clone --depth 1 https://github.com/USERNAME/minimal-r-project-with-make.git new-project
git remote remove origin

Use your own USERNAME if you forked the repository to your own account, or bjcairns if you did not. (Note: --depth 1 means that only the latest revision is cloned, and git remote remove origin severs the link between your new project and the GitHub repository. You can set a new remote if you wish.)

Next use GNU make to build the example analysis report. At the command line, type:

cd new-project
make

You can also try:

make clean
make test
make report

The make clean command deletes all contents of the output directory in preparation for a fresh build of the project. If the tests are run (on a fresh build, or after make test), test results will be sent to stdout and also to file output/tests.txt.

After successful completion of make (or make report), you can find the HTML report in file output/report.html, a trivial example using R's built-in timeseries dataset, AirPassengers.

License

This work is licensed under the MIT License, meaning that you can do what you like with it provided that you include a copy of the permission notice (file LICENSE) with any copies or substantial portions of the software.

However, any actual analysis project (i.e. not an example or template project like this one) is likely to retain only minor portions of this template. In that case you could:

git rm LICENSE
echo "# My new project" > README.md
git add README.md
git commit -m "Delete original LICENSE and replace README.md"

and continue developing your project. Don't forget to add a new LICENSE file if you choose to share your work.

About

A minimal data analysis project in R, using GNU make, R Markdown, and unit tests

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Makefile 59.4%
  • R 40.6%