similar to: Can R scripts executed in batch mode take a commandline argument?

Displaying 20 results from an estimated 4000 matches similar to: "Can R scripts executed in batch mode take a commandline argument?"

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
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
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,
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
2009 Jul 13
2
how to run a R program with input arguments
I am a beginner in R and know only a little about it yet. I have a script written in R language, named as "a.txt" for example. I am using a Linux machine, at present I only know that I can type "R" in the terminal and then copy-paste the content in "a.txt" to the R's interface to execute the program. However, I want to know if there is any method that allows me to
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)) }
2007 May 16
2
Running R function as a Batch process
Hi, I am struggling with using R CMD BATCH command. Kindly suggest solution to the following problem. I have a function named CinC with accept two input parameters. This can be shown as: CinC <- function(start, end) where start and end both are character strings. Please suggest me how can I run this function using command R CMD BATCH. Currently I am trying to do like this -> R CMD
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
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 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
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]);
2011 Jul 02
5
%dopar% parallel processing experiment
dear R experts--- I am experimenting with multicore processing, so far with pretty disappointing results. Here is my simple example: A <- 100000 randvalues <- abs(rnorm(A)) minfn <- function( x, i ) { log(abs(x))+x^3+i/A+randvalues[i] } ?## an arbitrary function ARGV <- commandArgs(trailingOnly=TRUE) if (ARGV[1] == "do-onecore") { ?library(foreach) ?discard <-
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",
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
2017 Jun 12
2
Bucle for que se salte los errores
He encontrado la respuesta. EL ejemplo que puse era trivial, ya que es obvio que if(i ==0) entonces next, pero me referia a sin saber si va a ser error el modelo o no. Para esto he encontrado la solución for(i in -3:3){ tryCatch({ z<-1/i > z<-z*z > modelo<-lm(z~1) }, error=function(e){print("es un error"}) } Gracias de todas maneras!!!!! Jesús
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
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.
2010 Sep 13
4
Problem with WARNING...headers with CRLF line endings
Dear all, When running R CMD check on Windows XP to test my package I get the following warning message: "* checking line endings in C/C++/Fortran sources/headers ... WARNING Found the following sources/headers with CR or CRLF line endings: src/xpsDict.h" The problem is that this file is created by the compiler AUTOMATICALLY during the compilation process, and since the file is
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)
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