Displaying 20 results from an estimated 12000 matches similar to: "using var from bash in R script"
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
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
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.
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
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",...)
2012 Jun 18
1
Error w/ Start up Script
I noticed about a couple weeks ago that my R start up script starting showing the below errors, following the line "Type 'q()' to quit R"
Not sure what I did different and so far it hasn't caused major problems but kind of fear that it will.
Can you please help?
I also posted my Rprofile below.
Attempting to load the environment 'package:R.utils'
R.methodsS3 v1.2.2
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
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
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 =
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
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,
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
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
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
2009 Mar 02
2
Bash script that uses an R command
I have wriiten (with the help of the internet) a bash scirpt for my
debian ppc 5.0 laptop to display battery remaining in a panel on the
xfce desktop environment.
echo `hal-device | grep battery.remaining_time | awk '{print $3/3600}' `-battery
and this nicely spits out 4.95 hours in the panel. This is fine
except it is a snow day and I have some extra time on my hands. I was
wondering
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"
2003 Dec 17
1
smbclient null-password behavior differs between 3.0 and 2.2.8a
When I made the move to 3.0, I noticed that smbclient no longer works
with null passwords. Am I missing something? I read the FAQ, which
suggests that the server is rejecting the null password. But I know
that null passwords work fine for the 2.2.8a client, so the server is
not the issue. The FAQ recommends "smbclient -L host -U%", but I
don't want to set the username to null. I
2004 Feb 12
2
calling R from a shell script and have it display graphics
Hello,
I am running R under Linux/x11.
I would like to call R from a shell script and have it display a series
of graphics.
The graphics should remain visible until the user clicks or presses a key.
I first tried R BATCH, but it does not load the x11 module, making it
impossible to open x11 or png devices.
Then, I tried to call R with a 'here' script:
R --vanilla --quiet --args
2017 Jul 12
1
submitting R scripts with command_line_arguments to PBS HPC clusters
Hi,
The problem is most likely, you need to call a R CMD BATCH with your arguments and the R-script inside of a shell script that you submit to your qsub.
Unfortunately we don't use qsub anymore so can't test it, but it should be as follows:
R-script eg. test.R:
> ##First read in the arguments listed at the command line
> args=(commandArgs(TRUE))
>
> ##args is now a list of