similar to: Command line option to an R script running through Rscript

Displaying 20 results from an estimated 20000 matches similar to: "Command line option to an R script running through Rscript"

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
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,
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
1
Why this statement does not print anything in an if-statement that includes 'q()'?
Hi, I run the following script. I don't understand why the second 'length(args)' does not show anything but the first one shows '0'. Is it because the command 'q()' affects anything in the if-statement. However, if I change the second 'length(args)' to 'print(length(args))', the script will print the length of 'args'. Can somebody let me know
2009 Sep 06
2
How to pop up the graphics window from Rscript?
Hi, I am wondering how to pop up the graphics window from Rscript. I run the following code, but I don't see the graphics window, even transiently. Regards, Peng $ Rscript plot.R > x=1:10 > y=1:10 > plot(x,y) >
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
2009 Sep 22
1
How to get the current script file name in the script?
Hi, Right now, I hardcode the file name in the script. But when I change the script name, I have to change the file name in the script to make sure the file name inside the script is synchronized with the script name. I am wondering if there is an automatic way to get the script file name in a script. Regards, Peng $ Rscript get_file_name.R > print('get_file_name.R') [1]
2009 Sep 06
2
How to wait for a user response in Rscript?
Hi, In 'example(barplot)' running in R, I see 'Hit <Return> to see next plot:', then R waits for my input. I am wondering how to wait for a user response in Rscript. Regards, Peng
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
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?
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 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
2014 Jul 01
1
combining data from multiple read.delim() invocations.
Is there a better way to do the following? I have data in a number of tab delimited files. I am using read.delim() to read them, in a loop. I am invoking my code on Linux Fedora 20, from the BASH command line, using Rscript. The code I'm using looks like: arguments <- commandArgs(trailingOnly=TRUE); # initialize the capped_data data.frame capped_data <- data.frame(lpar="NULL",
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
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)
2011 Nov 28
1
Running Shell Script with R
I'm having some trouble getting my shell script to work. I've checked out the Intro to R Manual and a host of other websites, but I still can't get the script to work when I submit the job to the cluster. Here is my main R code: ##Load Libraries ##... ## Load Time Data Args <- commandArgs(trailingOnly = TRUE); print(Args); timeDat <- read.flowSet(files=NULL, path=Args[1]);
2009 Sep 05
1
Is 'history' recorded in Rscript?
Hi, I run the following command and try to save the commands that have been run in the script. But it seems that no history is recorded. Is it because that the history is not recorded in Rscript? Regards, Peng $ Rscript savehistory.R > f=tempfile() > f [1] "/tmp/Rtmp7WBjGG/file327b23c6" > history() Error in savehistory(file) : no history available to save Calls: history ->
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 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