Skip to content

Instantly share code, notes, and snippets.

@brianspiering
Created May 3, 2015 15:37
Show Gist options
  • Save brianspiering/b6bc22825b4984992277 to your computer and use it in GitHub Desktop.
Save brianspiering/b6bc22825b4984992277 to your computer and use it in GitHub Desktop.
Template for R programs
#! /usr/bin/env Rscript
# File description -------------------------------------------------------------
#
#
# Setup packages ---------------------------------------------------------------
# List of packages for session
.packages = c("devtools",
"stringr",
"dplyr",
"ggplot2",
"knitr",
"markdown")
# Install CRAN packages (if not already installed)
.inst <- .packages %in% installed.packages()
if(length(.packages[!.inst]) > 0) install.packages(.packages[!.inst])
# Load packages into session
lapply(.packages, require, character.only=TRUE)
cat("\014") # Clear console
# General setup ----------------------------------------------------------------
rm(list=ls()) # Delete all existing variables
graphics.off() # Close all open plots
# Code Block -------------------------------------------------------------------
# TODO: Add code
# Tidy things up ---------------------------------------------------------------
cat("\014") # Clear console
# Scratchpad -------------------------------------------------------------------
# print( "Hello, world!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment