Friday, June 06, 2014

Command line

  • R is used more and more
  • So also for executing R-scripts

Typical usage

#!/usr/bin/Rscript
my_model <- lm(data=iris, Sepal.Width ~ Sepal.Length)
print(coef(my_model))

Typical usage

#!/usr/bin/Rscript

my_data <- iris
dep <- "Sepal.Width"
indep <- "Sepal.Length"

f <- as.formula(paste0(dep, " ~ ", indep))
my_model <- lm(data=my_data, f)
print(coef(my_model))

Getopt

test