similar to: Rscript, hashbang, and arguments

Displaying 20 results from an estimated 1000 matches similar to: "Rscript, hashbang, and arguments"

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)) }
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 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 Jul 22
4
glmnet with binary logistic regression
Hi all, I am using the glmnet R package to run LASSO with binary logistic regression. I have over 290 samples with outcome data (0 for alive, 1 for dead) and over 230 predictor variables. I currently using LASSO to reduce the number of predictor variables. I am using the cv.glmnet function to do 10-fold cross validation on a sequence of lambda values which I let glmnet determine. I then take
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.
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)
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 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
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",
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 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)
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 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
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
2008 Oct 15
1
Can R scripts executed in batch mode take a commandline argument?
I have examined the documentation for batch mode use of R: R CMD BATCH [options] infile [outfile] The documentation for this seems rather spartan. Running "R CMD BATCH --help" gives me info on only two options: one for getting help and the other to get the version. I see, further on, that there are options for retoring and saving sessions (which I do not need to do in this case),
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
2011 Oct 19
1
Cairo creates italized plots?
Hi, Has anyone else run into this weird behaviour where the text in the plots created using Cairo are always italicized. For example, library(Cairo) Cairo(file='cairo_created', type='pdf', dpi=100) plot(1:10) dev.off() This produces the following attached 'cairo_created.pdf' graph. Notice how the text is italicized. The same code but using pdf() as the graphics
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