search for: commandargs

Displaying 20 results from an estimated 162 matches for "commandargs".

2007 Apr 01
2
commandArgs usage and --args invokation
Dear R experts: I am a bit stymied by how the argument picking-off works in R batch file usage. $ cat commandArgs.R cat(" Command Line Arguments were ", commandArgs(), "\n"); $ /usr/bin/R CMD BATCH commandArgs.R --args 1 2 3 $ /usr/bin/R --args 1 CMD BATCH commandArgs.R ... I am now getting into interactive mode ?! I guess it really is skipping the rest of the command line $ /usr/bin/R...
2010 Jan 10
0
commandArgs return value
Hello, I plan to use a script with R CMD BATCH on different platforms Linux, Windows and Mac OSX. I use the commandArgs(trailing = FALSE) function to retrieve the name of the script and the arguments (example below with output.) The online docs for "Introduction to R" (sections B.1 Invoking R from the command line and B.4 Scripting with R) and help("commandArgs") leave my head spinning...
2002 Jun 25
1
commandArgs: feature request
Dear R-core Team, As Thomas Lumley pointed out in one of his e-mails one can use commandArgs() to get a copy of the command line arguments supplied when R session was invoked and then use grep to extract parameters of interest. His solution works very well if the custom options are passed by names, e.g. --my-option=value, but what if one wants to pass parameters by their positions. Then it...
2003 May 05
1
commandArgs()
Apologies for asking about this, but I don't quite understand how this works after looking through the FAQ and the Help archives. Let's say I want to pass "1000" as an argument to R. I did the following: >R CMD BATCH --1000 infile outfile When I do print( commandArgs() ), I see [1] ".../R.bin" "--restore" [3] "--save" "--no-readline" [5] "gui=none" "--1000" So commandArgs()[6] is the argument I want. Does one then go on and remove the "--" manually and cast this...
2003 Feb 05
0
commandArgs() prints warnings to STDOUT - correction
I realized that it is not commandArgs() rather R itslef that prints the warning to the stdout (which is still not desirable of course): $ R --no-save --no-restore --silent A < /dev/null 2> /dev/null ARGUMENT 'A' __ignored__ =======original message below======== Dear R-Users, I was glad to hear that there is an ongoi...
2005 May 10
2
filename
Hey, I'm generating a .jpeg file for a web application passing parameters to R via cgi. R gets the parameters by using commandArgs, which are passed to a variable named j and z j<-commandArgs()[3] z<-commandArgs()[4] Later I want to use the characters strings of the argument which the variables are holding for my filename, e.g.: jpeg(file="d:/data/images/jz.jpeg",...) i tried to use paste and as.characte...
2009 Feb 17
3
R scripts and parameters
A couple of weeks ago I asked how it is possible to run an R script (not a function) passing some parameters. Someone suggested the function "commandArgs()". I read the on-line help and found no clarifying example. Therefore I do not know how to use it appropriately. I noticed this function returns the pathname of the R executable which is not what I need. I meant to ask if it is possible to open an R session and launch a script passing parame...
2011 Apr 09
1
How do I make this faster?
...w, in hopes that somebody will be able to figure out how to make it faster, either through parallelisation, or by making changes. I've marked the places where Rprof showed me it was slowing down: currencyCorrelation <- function(lagtime = 1) { require(quantmod) dataTrack <- getSymbols(commandArgs(trailingOnly=T)[1], from='2009-11-21', to='2011-04-03') stockData <- get(dataTrack) currencies <- row.names(oanda.currencies[grep(pattern='oz.', fixed=T, x =as.vector(oanda.currencies$oanda.df.1.length.oanda.df...2....1.)) == F]) correlations <- vector() val...
2008 Jan 05
1
Rscript argument processing minor bug with -g
...language R version.string R version 2.7.0 Under development (unstable) (2008-01-04 r43862) [fedora core 5] ## No problem with -a -b -f -h ~/src/scripts/R> /usr/src/R/R-devel/bin/Rscript -e "commandArgs()" -a -b -f -h [1] "/usr/src/R/R-devel/bin/exec/R" "--slave" [3] "--no-restore" "-e" [5] "commandArgs()" "--args" [7] "-...
2009 Aug 28
1
How to convert a string passed as an argument to a vector?
Hi, $ cat commandArgs.R args=commandArgs(trailingOnly=TRUE) args[1]+10 I have the above code. But the following command line gives me an error. I am wondering what is the correct way to convert a string to a vector? $ Rscript commandArgs.R 1:3 > args=commandArgs(trailingOnly=TRUE) > args[1]+10 Error in args[1] +...
2011 Mar 14
1
Rscript, hashbang, and arguments
...typically run these scripts by passing in some parameters like this: ./nameOfRScript arg1 arg2 ... I know Rscript has the option to run in --vanilla. Where exactly do I insert the --vanilla option? When I do something like this: ./nameOfRScript --vanilla arg1 arg2 ... And I try to access the commandArgs, the first argument is --vanilla which isn't what I want. I tried to do commandArgs(trailingOnly=TRUE) with ./nameOfRScript --vanilla --args arg1 arg2 ... But I sitll have the first argument as --vanilla. Does anyone know how to get around this? Thanks, Fong [[alternative HTML version d...
2012 Mar 28
2
getopt does not work as expected!
...n/Rscript spec=matrix(c( 'verbose', 'v', 1, "integer", 'help' , 'h', 0, "logical" ),ncol=4, byrow=TRUE) spec.dim=dim(spec) spec.opt.long=spec[,1] spec.opt.short=spec[,2] spec.opt.l <- spec.dim[1] infile <- "test.dat" args=commandArgs(TRUE); l=length(args) self = commandArgs()[1]; usage <- function() { print(sprintf("Usage: %s [--verbose|-v] [--help,-h] [infile.dat]"),self) print(sprintf(" default infile.dat = '% s'",infile)) } library('getopt') opt = getopt(...
2012 May 03
1
is there a way of identifying batch mode running?
Hello list Is there a way of identifying from within R whether a script has been source(d) from Rgui.exe or via Rscript.exe in batch mode? For the code I have I use the commandArgs() function to pick up command line args when running in batch mode via Rscript.exe However I like to get the code working manually first using source("MyRCode.r") I'd like to be able to put something at the top of the file that discriminates between the two running modes eg #Rscrip...
2005 Sep 23
1
R's parsing of command line arguments using commandArgs()
...They would create these values at run time, based upon specs that I give them. Using the following as an example: $ R --slave --vanilla --args "c(5,5)" "c(.5,.5)" < RScript.R I can then process "c(5,5)" and "c(.5,.5)" as two arguments, via: Args <- commandArgs() where the two arguments are Args[5] and Args[6], respectively. I can then of course pass these as "eval(parse(text = Args[5]))" to other R functions. However, if there is any whitespace in the two arguments, such as: R --slave --vanilla --args "c(5, 5)" "c(.5, .5)&quo...
2007 Mar 20
2
run a script during R CMD build
I would like R CMD build to run some R code which does some stuff and save the result as a file in /inst/docs folder. Is there any way of doing this. Thank you. Johan ____________________________________________________________________________________ We won't tell. Get more on shows you hate to love [[alternative HTML version deleted]]
2012 May 22
2
Best way to locate R executable from within R?
...ay not be on the OS's search path. What is the best way, from within a running R, to infer the command (basename or full path) for launching R in way that it works on any OS? I came up with the following alternatives, but I'm not sure if they'll work everywhere or not: 1. Rbin <- commandArgs()[1]; 2. Rbin <- file.path(R.home(), "bin", "R"); Other suggestions that are better? /Henrik
2012 Oct 29
6
export variable from bash to R
...elped me with this: I am trying to automate the execution of an R script (let's call it "myscript.R") by passing a variable from a bash script to myscript.R. I know I can use the command Rscript, but I don't know how to declare in bash which variable will be accessed by the "commandArgs" command in myscript.R. So my bash script looks about like this: #!/bin/bash VARIABLES=( a b c d ) for i in ${VARIABLES[@]}; do VARIABLENAME=$i Rscript -e 'source("myscript.R")' done In myscript.R, I would like to use the current VARIABLENAME when executing the progra...
2012 Jan 04
2
using var from bash in R script
Dear R users, This probably a really noob question, but I'm stuck. I'd like to pass some variables from bash to R as strings. I can successfully pass variables using commandArgs(), the problem is that I end up with an array. So, for example: > Args <- commandArgs(TRUE) > Args [1] "one" "two" "three" Now, it just so happens that "one", "two", "three" are names of columns that I'd like to work wit...
2007 Jan 24
1
writing R shell scripts?
Hi All, Another newbie question. I want to write an R script that takes argument from command line and runs and produces output to stdin. For example if there is file foo.R with following in it. args = commandArgs() print(args) then, when I run it like $ R foo.R hello it should print 'hello' on the terminal. I searched the mainling list and found a very old post that said said that this feature will be implemented soon. I am expecting this has already been implemented by now. Thanks, Deepak
2018 Sep 16
4
Rscript -e does not accept newlines under Linux?
Hello, I have found what I believe to be a bug in the Linux version of the Rscript binary. Under Windows (official 64-bit 3.5.1 R distribution running on an up-to-date Win10), I can do the following (e.g. under powershell): PS H:\Users\Cesko> Rscript -e 'ls() >> ls()' character(0) character(0) which works as I expect: I am running Rscript with two arguments, namely (1)