Skip to content

Instantly share code, notes, and snippets.

@k-hench
Last active July 4, 2019 10:01
Show Gist options
  • Save k-hench/6e9982c2ace632093bef2358ee471d07 to your computer and use it in GitHub Desktop.
Save k-hench/6e9982c2ace632093bef2358ee471d07 to your computer and use it in GitHub Desktop.
#!/usr/bin/env Rscript
# run from terminal:
# Rscript --vanilla test_agrs.R input1 input2 inputA 16
# ===============================================================
# This script
# ---------------------------------------------------------------
# ===============================================================
# args <- c('input1','input2','inputA','16')
args = commandArgs(trailingOnly=FALSE)
# setup -----------------------
library(tidyverse)
library(hypogen)
library(hypoimg)
script_name <- args[5] %>%
str_remove(.,'--file=')
plot_comment <- script_name %>%
str_c('mother-script = ',getwd(),'/',.)
args = args[7:length(args)]
cat('\n')
cli::rule( left = str_c(crayon::bold('Script: '),crayon::red(script_name)))
cat(' ')
cat(str_c(crayon::green(cli::symbol$star),' ', 1:length(args),': ',crayon::green(args),'\n'))
cli::rule(right = getwd())
# config -----------------------
param_1 <- as.character(args[1])
param_2 <- as.character(args[2])
param_3 <- as.character(args[3])
param_4 <- as.numeric(args[4])
# start script -------------------
# ADD CONTENT HERE
# export graph
hypo_save(p1, filename = 'plots/plot.pdf', width = 16, height = 9,
comment = plot_comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment