This is a template for R projects that should work both on the command line as well as in an interactive session.
The template is made up of three files:
-
foo.r
Contains all of the actual code of the application.
-
cli.r
Contains the command line interface to the application. It is to be executed via:
Rscript cli.r --help
Use command line arguments to configure the application.
-
session.r
Contains the interactive session interface to the application. Just open the file in RStudio and click the source button or use its keyboard shortcut
CTRL + SHIFT + S
.Modify the variables in the configuration section to configure the application.
To start a new R project using this template, use git:
# get a copy of the template
user@host ~/projects $ git clone https://gist.github.com/wookietreiber/0ff145270c75f11e956284412b3847b8.git project
Cloning into 'project'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 6 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
# initialize new git repository
user@host ~/projects $ cd project/
user@host ~/projects/project $ rm -fr .git
user@host ~/projects/project $ git init
Initialized empty Git repository in /home/user/projects/project/.git/
# hack away - may the source be with you!