Skip to content

Instantly share code, notes, and snippets.

@brianspiering
Created March 17, 2019 15:27
Show Gist options
  • Save brianspiering/cc66a3e7381c80a687d7abf039417a22 to your computer and use it in GitHub Desktop.
Save brianspiering/cc66a3e7381c80a687d7abf039417a22 to your computer and use it in GitHub Desktop.
Template for R files
#! /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("\f") # 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("\f") # Clear console
# Scratchpad -------------------------------------------------------------------
# print( "Hello, world!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment