Commit 2c73d150 authored by Lena Hersemann's avatar Lena Hersemann

added template for R scripts

parent f9eb3a78
#!/usr/bin/env Rscript
##TODO: define title and objective
#' # Report Title
#' Objective: Analysis objective
#'
#' Created by: `r system("whoami", intern=T)`
#'
#' Created at: `r format(Sys.Date(), format="%B %d %Y")`
#-----------------------------------------------------------------------------------------------------------------------
#+ include=FALSE
suppressMessages(require(docopt))
##TODO: specify function of the script, usage (name of R script and required input data) and optional parameters with type (e.g. boolean, file, etc.), a description and the default setting
doc = '
Function of the script
Usage: script_name.R [options] <required_input_1> <required_input_2>
Options:
--parameter_1 <parameter_type> parameter description [default: parameter_default]
--parameter_2 <parameter_type> parameter description [default: parameter_default]
'
#commandArgs <- function(x) c("--argument_1", "argument_1_setting", "required_input_1", "required_input_2")
opts = docopt(doc, commandArgs(TRUE))
#-----------------------------------------------------------------------------------------------------------------------
## REQUIRED PACKAGES
devtools::source_url("https://git.mpi-cbg.de/bioinfo/datautils/raw/v1.45/R/core_commons.R")
#TODO: load all additionally required packages
## NEWLY DEFINED FUNCTIONS
#TODO: define new functions if required
#-----------------------------------------------------------------------------------------------------------------------
#TODO: write script with commented code
#-----------------------------------------------------------------------------------------------------------------------
## ADDITIONAL INFORMATION EXPORT
## export R version and package infos
writeLines(capture.output(devtools::session_info()), ".sessionInfo.txt")
## save R session as hidden file
#TODO: use the R script's name as a name for the session file
session::save.session(".script_name.dat")
# session::restore.session(".script_name.dat")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment