Is it possible to read commandline arguments when running R interactively? -


this question has answer here:

i've got r script run via rscript i'd able run interactively in r play of resulting data - problem is, tries read commandline arguments via commandargs , doesn't seem work in r interactive shell. i'd able start r shell commandline arguments i'd pass script , have read them when source script.

$ r arg1 arg2  r version 3.1.2 (2014-10-31) -- "pumpkin helmet" copyright (c) 2014 r foundation statistical computing platform: x86_64-pc-linux-gnu (64-bit)  ... > args <- commandargs(trailingonly = true) > args character(0) > source("myscript.r") ... fails because myscript.r depends on args 

arg1 , arg2 don't seem passed along r shell.

if pass command line arguments this: r --args 1 2, can access them follows:

> args = commandargs(trailingonly=true) > args [1] "1" "2" 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -