Questions tagged [rscript]

Rscript (Rscript.exe on Windows) is a binary front-end to R, for use in scripting applications.

Rscript (Rscript.exe on Windows) is a binary front-end to R, for use in scripting applications. It is included in the core R distribution since version 2.5.0.

littler is an alternative front end to R for use in '#!' scripts.

Example:

Rscript

#! /path/to/Rscript
args <- commandArgs()
args <- args[-(1:match("--args", args)]
cat('hello world!', args, "\n")

littler

#! /path/to/r
cat('hello world!', argv, "\n")

Rscript passes all script arguments to R as additional elements to the vector returned from commandArgs().

littler provides convenience by assigning the script arguments to an argv vector and placing that into the global environment, a convention followed by other popular scripting languages.

656 questions
3
votes
3 answers

How to run another Rscript after several R jobs running in parallel are done?

The arrangement on how I need to run my scripts is first to run the 4 R scripts in parallel using the rstudioapi::jobRunScript() function. Each of the scripts that is running in parallel does not import anything from any environment but instead…
Denelle
  • 55
  • 1
  • 7
3
votes
0 answers

RSelenium with Docker Fails in RScript but works in RStudio

I am trying to use the selenium/standalone-chrome Docker image, RSelenium, and an RScript to setup some automated web-scraping via my mac's command line. While the code below will work in RStudio, it won't work when I try to run it via RScript...I…
nate
  • 1,172
  • 1
  • 11
  • 26
3
votes
2 answers

Is there a way to debug an R script run from the command line with Rscript.exe

Is it possible to debug an R source file which is executed with Rscript.exe? > Rscript.exe mysource.R various parameters Ideally, I would like to be able to set a break-point somewhere in the mysource.R file in RStudio. Is entering the R debugger…
witek
  • 984
  • 1
  • 8
  • 25
3
votes
0 answers

package R scripts and its dependencies and reproduce them on different machine

Like virtualenv and requirements.txt in python based projects, I want to package R dependencies like RPostgreSQL, rJava, xlsx etc. and re-install them on another machine through automation. I tried using packrat on my…
murtaza1983
  • 247
  • 2
  • 8
3
votes
0 answers

How to let Rscript behave similar to other linux programs by not generating errors upon SIGPIPE?

Here are some related discussions. But I don't think the answers are relevant to my question. Piping Rscript gives error after output Normal linux commands work just fine upon receiving SIGPIPE $ seq 10 |head -n 1 1 But Rscript behaves differently…
user1424739
  • 11,937
  • 17
  • 63
  • 152
3
votes
1 answer

Python subprocess FileNotFoundError

I am trying to follow this blog on how to execute an R script from Python. I have the R script working fine from the command line using Rscript. Here's my Python code: import subprocess import os command = "C:\Program…
Tom Wagstaff
  • 1,443
  • 2
  • 13
  • 15
3
votes
1 answer

WScript.Shell to run a script with spaces in path and arguments from VBA

I need to call a script (R) from VBA using the WScript.Shell. The path to the file contains spaces. Additionally, a series of arguments is passed to the script, of which several also contain spaces. I have tried all thinkable combinations of quotes…
Sam
  • 191
  • 1
  • 7
3
votes
1 answer

Interactive Debugging in R

I have a toy R script (test.R) as follows: myString <- "Hello World" browser() print(myString) I want to interactively debug the script, hence the 'browser()' call. However, when I run the script like this: Rscript test.R I just see: Called from:…
nickos556
  • 337
  • 3
  • 16
3
votes
1 answer

How to export Variable when using runuser

I am trying to run Rscript as a different user under constrained environment with a user which do not have the access to /tmp. As the Rscript create a tmp file, it needs access to /tmp. So i thought if i can tell Rscript to change the tmp directory…
Bhuvan
  • 4,028
  • 6
  • 42
  • 84
3
votes
1 answer

Execution halted error in R

I run hicpipe tools and it returns this error during execution. Its error was: Rsge temp files: tmp/Rsge.test_cluster.binned.* Error in if (trace) cat("Running locally \n") : argument is of length zero Calls: compute.total.counts ->…
user3585775
  • 93
  • 1
  • 7
3
votes
1 answer

How to detect/handle user interrupt in Rscript

I have an R script designed for command-line execution via Rscript.exe that includes a long running loop that makes API calls and writes results to a database. The script includes error handling via trycatch for database cleanup: trycatch({ # api…
W. Murphy
  • 1,121
  • 8
  • 15
3
votes
1 answer

Running R via terminal in Windows and leaving R session open

Suppose that I have a R script called test.R, stored at C:\, with the following content: x <- "Hello Stackoverflowers" print(x) To run it via terminal one could simply call: Rscript C:\test.R And as expected, the result will be: However, what I…
Louis15
  • 295
  • 3
  • 12
3
votes
0 answers

Rscript.exe cannot open/read scripts, permission denied

So I'm trying to run some R scripts via cmd directly using Rscript.exe "C:\Users\xxxxx\Documents\test.R" but it fails every time with the same error : Fatal error: cannot open file 'C:\Users\xxxxx\Documents\test.R': Permission denied However, if…
Havimo
  • 61
  • 4
3
votes
3 answers

Rscript and user prompts

Have a fully working R-script. When executing it from Rscript it doesn't stop to accept user input however. The user input is some readline statements. The cat statements prompting for input works as intended. Have I missed something? I execute…
wabe
  • 93
  • 5
3
votes
1 answer

Edit a row value in datatable in spotfire

How do we edit a row in a datatable in spotfire? Can we do it using ironpython or R script? I have a requirement where I want to edit the values in spotfire datatable to see the effect in the respective visuals. The data table is populated using an…