Displaying 20 results from an estimated 3000 matches similar to: "commandArgs usage and --args invokation"
2009 Apr 12
2
Convert string to time
One variable contains values (1.30 - one hour and thirty minutes, 1.2
(which is supposed to be 1.20 - one hour and twenty minutes)). I would
like to convert to a minute variable so 1.2 is converted to 80
minutes. How?
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 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
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's
2024 Aug 23
1
Linear regression and stand deviation at the Linux command line
? Thu, 22 Aug 2024 13:07:37 -0600
Keith Christian <keith1christian at gmail.com> ?????:
> I'm interested in R construct(s) to be entered at the command
> line that would output slope, y-intercept, and r-squared values read
> from a csv or other filename entered at the command line, and the same
> for standard deviation calculations, namely the standard deviation,
>
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"
2005 Sep 23
1
R's parsing of command line arguments using commandArgs()
Hi all,
I am setting up some R program files for use by our DB programmers to
enable them to utilize some R functions which will be called from within
TCL code. R has been installed on an RHEL server and R will process the
results of SQL queries against an Oracle database.
In some cases, they will generate a data file to be read in and
processed by R, in others they will simply make the
2008 Jul 01
4
passing a variable at the command line
Dear R People:
I have used
./R --no-save -q -f e.in >stuff.out
with great success on SUSE10.1 with R-2.7.1.
My question is, please: is there a way to pass in a variable to the
e.in file? I'm fairly sure that the answer is no, but thought I'd
double check.
Thanks in advance,
Sincerely,
Erin
--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
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")
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 ongoing work to make R more easily
runnable as a batch. I'd like
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)
2011 Mar 23
1
How identify args into R, sent from a command line.
Hi,
For example, I have several variables in php, like
var1 = 1, 2, 3, 5, 6
var2 = 3, 1, 8
var3 = 8, 10, 4, 0, 9, 1
I sent the arguments to R, with this line:
'/usr/bin/R --vanilla --slave --args '.$var1.' '.$var2.' '.$var3.' < script.r'
In my "script.r" I can read the arguments whit this line:
args=(commandArgs(TRUE))
args=as.numeric(args)
args
2007 Aug 01
2
passing args to R CMD BATCH in win 2000
Hello and sorry to bother.
Please help.
I searched the archives but could not find out why --args is being ignored
on Windows 2000.
I try
R CMD BATCH --slave 11.R 11.Rout --args "12"
and 11.R has
x=commandArgs(trail=T)
print(x)
a=x[length(x)]
write.csv(a,file="13.out")
q("no")
the argument is not passed to the R process.
11.Rout only shows processing time and
2009 Apr 17
1
args and test of passed paramters
Hi,
I would like to call a R script sometimes with:
R --slave --vanilla --args Debug=1 N=25 < test.R
and sometimes with
R --slave --vanilla Debug=1 < test.R
or similar.
Inside the R script I get the arguments with:
args=(commandArgs(TRUE))
if(length(args)==0){
print("=== No arguments supplied. =============")
}else{
for(i in 1:length(args)){
2009 Jun 18
1
Calling library functions from outside R
I develop quite a bit of R code that I tend to distribute, or let
other people embed in their software. One of the things I'd really
like to do is find a way to load an R library I've developed, and call
one function with arguments.
Currently, I achieve that by building a separate R client file, which
reads in the command line arguments, loads the library, and calls the
main
2011 Apr 09
1
How do I make this faster?
I was on vacation the last week and wrote some code to run a 500-day
correlation between the Nasdaq tracking stock (QQQ) and 191 currency pairs
for 500 days. The initial run took 9 hours(!) and I'd like to make it
faster. So, I'm including my code below, in hopes that somebody will be able
to figure out how to make it faster, either through parallelisation, or by
making changes. I've
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",...)
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
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
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 =