Displaying 20 results from an estimated 10000 matches similar to: "R's parsing of command line arguments using commandArgs()"
2011 Mar 14
1
Rscript, hashbang, and arguments
Hi,
I have a bunch of R scripts which have the hash bang !/usr/bin/env Rscript
and I 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,
2012 Sep 06
1
[Rscript] difficulty passing named arguments from commandline
Wanting a commandline solution (for a problem detailed @
http://mailman.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2012/msg00279.html
) I turned to Rscript, and whacked out the q'n'd
https://github.com/TomRoche/GEIA_to_netCDF/blob/master/netCDF.stats.to.stdout.r
However it wasn't as quick as hoped, because I spent quite a bit of time
figuring out how to pass the arguments.
2014 Sep 18
1
last user argument missing from Rscript --verbose
The loop that echoes the arguments almost always stops too soon. It apparently does that to avoid
echoing the "--args" (that had been inserted) when there are no user arguments. However, when there
are user arguments, the next element of the 'av' array is the last argument and usually not "--args",
although it can be.
?Rscript is a little sketchy:
?--verbose?
2008 Jan 05
1
Rscript argument processing minor bug with -g
I think there's a minor bug in the argument-processing carried out by Rscript.
The effect is that if one passes "-g" as a flag to the script, it is erroneously
exposed to the main executable's argument processing and therefore generates a
message about not being able to comply with the request for a particular GUI.
Uppercase G is fine as are the other 25 letters in upper or
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
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)
2009 Aug 05
1
exec subdirectory of a package
Hello,
WRE contains the following information about the "exec" subdirectory of
a package :
"Subdirectory exec could contain additional executables the package
needs, typically scripts for interpreters such as the shell, Perl, or
Tcl. This mechanism is currently used only by a very few packages, and
still experimental."
I think it would be useful to expand "very
2017 Oct 20
1
Rscript Bug Report (improper parsing of [args])
Hi,
A user of my `optparse` package discovered a bug in Rscript's parsing of
[args]. (https://github.com/trevorld/optparse/issues/24)
I've reproduced the bug on my machine including compiling and checking the
development version of R. I couldn't find a mention of it in the Bug
Tracker or New Features.
Can be minimally reproduced on the UNIX command line with following
commands:
2017 Dec 05
2
command line arguments are parsed differently on windows, from 3.4.3
Sorry for not reading carefully and thanks for confirming problem with
Rscript too.
On Dec 5, 2017 08:47, "G?bor Cs?rdi" <csardi.gabor at gmail.com> wrote:
> On Tue, Dec 5, 2017 at 4:40 PM, Henrik Bengtsson
> <henrik.bengtsson at gmail.com> wrote:
> > One comment:
> > For your R devel example you didn't use spaces in the expression, i.e.
> maybe
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
2013 Mar 24
0
Rscript does not load/capture all shell arguments
Hi,
I am working on a GRASS script (bash script), which should run a R script.
I am working on Ubuntu 12.10, with R 2.15.3 and GRASS GIS 7.0 (I am not
sure the latter isn't really relevant as the grass script is just a bash
script). The R script is evoked with a call to Rscript ($RGRASSSCRIPT is a
shell variable with the file name of the R script, the rest are variables I
want to read into R)
2017 Dec 05
2
command line arguments are parsed differently on windows, from 3.4.3
One comment:
For your R devel example you didn't use spaces in the expression, i.e.
maybe that's broken too with spaces?
Three questions:
Does it work if you avoid spaces?
Does it work if you use single quotes?
Does this also occur for Rscript?
Thxs
Henrik
On Dec 5, 2017 03:44, "G?bor Cs?rdi" <csardi.gabor at gmail.com> wrote:
I wonder if this is intended.
Thanks,
2012 Oct 29
6
export variable from bash to R
Dear R experts
This probably seems very easy to you guys, but I'm a beginner and would be
really glad if someone helped 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
2012 Mar 01
2
Rscript example
Hi there,
I am trying to find an example how to use Rscript
Let's suppose I want to pass 3 arguments (I don't want [options] and -e
[expressions] as described in help)
*on the command line
myRscript.R -arg1=value1 -arg2=value2 -arg3=value3
*In the script
#! /path/to/Rscript
args = commandArgs(TRUE);
>From what I see args is just a string, do I do things correctly ?
--
View this
2009 Aug 20
1
Command line option to an R script running through Rscript
Hi,
I know that I can use the following script to get the command line
options for an R script. But the output shows two many irrelevant
arguments. For example, I only want to pass "a", "b" and "c" to the
script. The first 5 elements in the variable 'args' are not what I
want. I am wondering what is the correct way to pass command line
options to an R script.
2009 Nov 10
1
Is it possible to detect whether running as Rscript?
I would like to write a block of code that runs when a script is being
run from Rscript, but not to run if the same file is being source()d,
or submitted via ESS, etc. As a gloss I would like to write a file
that looks somewhat like:
#!/usr/bin/env Rscript
my.func <- function(...) {
#do something...
}
if ( #is.running.Rscript# ) {
do.call(my.func, commandArgs(trailingOnly=TRUE))
}
2016 Oct 29
3
pasar argumentos de consola a un script de R que contiene source
Hola.
Tengo un script con la siguiente estructura.
#!/usr/bin/env Rscript
args = commandArgs(trailingOnly=TRUE)
source("carga-datos.R")
source("modelo.R")
y quiero llamar a mi script desde consola con
Rscript --vanilla miscript.R datos1.csv
De forma que se guarde como argumento el nombre del fichero que quiero
cargar y se pase a al script carga-datos.R. El problema es
2009 Sep 07
2
Writing R Scripts and passing command line arguments
Hi Guys
I am Abhishek, primarily a bioinformatician. I have recently started using
a lot of R thanks to some excellent packages available.
Lately I have felt the need to batch process few of the R scripts I have
been working with and strangely enough I am not able to find a good resource
on how to best do this. I did find few old threads on the archives but none
convinced me much. So here I am
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] + 10 : non-numeric argument to binary operator
Execution halted
Regards,
Peng
2012 Mar 28
2
getopt does not work as expected!
I have the following script (also attached):
#!/usr/bin/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 =