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
1
vote
0 answers

How can I create a class with constructor and functions in R like java or c++?

I want to write R script class like java or c++ programming language. But, I didn't find any example. Here is the main structure of a class in java or c++: Myclass{ param1 param2 ... Constructor(...){ . . . } …
mohammad
  • 175
  • 2
  • 13
1
vote
1 answer

R, macosx, Rscript Fatal error: creating temporary file for '-e' failed

I'm running R 3.6.0 on Mac osx 10.11.6 (El Capitan) and get an "Fatal error: creating temporary file for '-e' failed" error when calling Rscript via system(). test_cmd <- "/Library/Frameworks/R.framework/Resources/bin/Rscript -e…
leonfrench
  • 193
  • 1
  • 8
1
vote
0 answers

Not able to connect MYSQL from Rscript in docker

I have downloaded the MYSQL docker image locally. Now trying to run Rscript in docker to connect to MYSQL using host given in the IPaddress section of Docker inspect (say “172.17.0.2” ), port 3306, username: root, and database: MySQL. RScript…
1
vote
1 answer

How do I open an r script (.R file) in RStudio by double-clicking it in windows

When I double click an R script (.R file) in order to open and edit it, nothing happens. I expect it to open it in either R or RStudio but it doesn't. I found a similar (old) question (Opening a .R file via a double click (Windows)) but the solution…
1
vote
1 answer

How to address an Rscript parse error: premature EOF?

Running my working R script in the windows command line (cmd) using Rscript results in a parsing error (premature EOF). When I run the script in RStudio, it compiles and runs as expected. I have read the Rscript page in R documentation, and I see…
1
vote
1 answer

Split the time difference to individual hours

I have a data.table which contains date and timestamps for start and end date. I know I can calculate the time difference by using the difftime function. But I want to calculate the time difference and split it into individual hours in each row…
prathyusha
  • 11
  • 4
1
vote
0 answers

Calling mclapply from Rscript

When calling a function which uses mclapply() with Rscript myFuction.R --json=config.json the mclapply functions fails with message all scheduled cores encountered errors in user code However when I run the code within RStudio it runs fine. I'm…
JoeMG
  • 11
  • 2
1
vote
1 answer

Heroku and R Build Error: "‘LC_MESSAGES’ undeclared"

I recently attempted to upgrade a Heroku app from Cedar-14 to Heroku-16. I am using this: Heroku buildpack for R. After the switch a bunch of R dependency install errors popped up, starting with error: ‘LC_MESSAGES’ undeclared (first use in this…
Matt Fordham
  • 3,147
  • 10
  • 34
  • 51
1
vote
0 answers

Image name of Rscript process in windows

I am running a batch script that starts several .exe and .R scripts and waits for them to finish before doing something else. Right now, the code to check if they have finished runs tasklist and sees if any of the .exes or Rscript.exe is still…
fdiogo
  • 11
  • 2
1
vote
1 answer

Running programmatically created Rscript call at command line

I have the following script: rstest text=$1 cmd="Rscript -e \"a='$1'; print(a)\"" echo $cmd $cmd This is the output I get when I run it: balter@spectre3:~$ bash rstest hello Rscript -e "a='hello'; print(a)" Error: unexpected end of input Execution…
abalter
  • 9,663
  • 17
  • 90
  • 145
1
vote
2 answers

Run Rscript using ProcessStartInfo from C#

On executing below code I dont get expected value (8) in result variable? Where am I going wrong? Code executes without any error but value of the result variable will be blank throughout R code:(Script.R) AddTwo<-function(firstNumber,…
Kuntady Yathish
  • 49
  • 2
  • 10
1
vote
0 answers

Running RScript from excel Permission denied Error Code 70

I am trying to run Rscript from Excel VBA and I receive the following error. I tried different things but just cannot make it work. Could someone please help? Function Run_R_Script(sRApplicationPath As String, _ sRFilePath As…
iamGV
  • 11
  • 1
1
vote
0 answers

Is C# Process re-escaping characters in string read from R script output?

I am trying to read an Json output from R script, my R file (RScript.R) looks like this : cat("[{\"code\":0,\"message\":\"FILE1.xls has been successfully checked.\"}]") I created in C# a method that runs the R script that looks like this: …
Cosmin
  • 152
  • 3
  • 18
1
vote
1 answer

simple Join error where some rows join and some don't

I have two dataframe which I'm trying to join which should be straight forward but I see some anomalous behavior. Dataframe A Name Sample Country Path John S18902 UK /Home/drive/John BOB 135671 USA …
Kp_Data
  • 21
  • 3
1
vote
0 answers

R *** caught segfault *** address 0x18, cause 'memory not mapped

I am running a pipeline that uses R on terminal to run a script: R version 3.5.2 (2018-12-20) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Mojave 10.14.3 I suddenly get this error. I have checked other users errors and tried to…
Ecg
  • 908
  • 1
  • 10
  • 28