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
5
votes
1 answer

R execution issue - No function found corresponding to methods exports from 'Runuran' for: 'initialize', 'show'

I am trying to run an Rscript. Each time it throws a warning message: "no function found corresponding to methods exports from 'Runuran' for: 'initialize', 'show'" while loading the package Runuran, and execution gets halted with the following…
IPS
  • 51
  • 3
5
votes
3 answers

Rscript and Packages: How and when to determine what packages are loaded?

I want to execute a script file.R using Rscript. In file.R, I use the package dplyr. # file.R df <- data.frame(ID,x,y,z,...) library(dplyr) filter(df, ID != "null") ...... If I don't specify any options in the batch-file, everything works fine as…
rmuc8
  • 2,869
  • 7
  • 27
  • 36
5
votes
3 answers

R: RScript Vector as argument

i am using the preinstalled package RScript in R. I want to call the following R-Script with the name 'test.R' from the command prompt: a <- c("a", "b", "c") a args <- commandArgs(TRUE) b <- as.vector(args[1]) b I use the following…
Loomis
  • 141
  • 1
  • 2
  • 4
5
votes
1 answer

How do `.sublime-build`s work?

Update: My problem has evolved after trying various things detailed in the comments to this question. The problems previously described in this question may indeed have been due to bad JSON, as suggested by @apple16, or related to my "$PATH"…
user109114
  • 403
  • 4
  • 10
5
votes
2 answers

user input in R (Rscript and Widows command prompt)

I am trying to figure out, how can i run an r script, using Rscript in windows command prompt and ask for user input. So far, i have found answers on how do ask for user input in R's interactive shell. Any effort in doing the same with readline()…
user1834437
5
votes
2 answers

Error Installing minqa in R/3.0.2

I am installing lme4 using the README.md file on their github account and I fail during installing the dependencies. I tried to install them separately and still crash at installing the minqa package. I'm using R/3.0.2 on RHEL6. During the build…
HoofarLotusX
  • 562
  • 2
  • 5
  • 11
5
votes
3 answers

Set value of --args from within R session

I would like to use the evaluate package to simulate executing (lots of) r-scripts while recording the outputs using evaluate. Evaluate is designed to do exactly this and it works almost out of the box. However, when using Rscript, the user passes…
Jeroen Ooms
  • 31,998
  • 35
  • 134
  • 207
4
votes
1 answer

rmarkdown execution of code inside a variable

I have code similar to the following, which is dynamically generated and stored in a variable: --- title: "test" author: "me" date: "3 June 2019" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ```{r,…
Dev Ops
  • 127
  • 1
  • 10
4
votes
1 answer

Creating a portable version of R for Mac (and installing package from source for this version)

I am trying to create a completely portable version of R for Mac that I can send to users with no R on their system and they can essentially double click a command file and it launches a Shiny application. I'll need to be able to install packages…
ZRoss
  • 1,437
  • 1
  • 15
  • 32
4
votes
2 answers

R.exe and Rscript.exe

I'm new to programming and I'm confused on the difference between the two. I have googled this and I am still confused on the difference after reading the responses. Part of the reason I am confused is I am thinking in terms of running script in…
fyb123
  • 43
  • 1
  • 5
4
votes
0 answers

R: Memory Allocation on Ubuntu for R vs Rscript

I have created a script, and when I run it line-by-line on Ubuntu, everything works from end-to-end, however, when I run it using Rscript it fails due to a memory allocation error. I have tried to remove excess variables using rm followed by gc, and…
Esben Eickhardt
  • 3,183
  • 2
  • 35
  • 56
4
votes
2 answers

Executable .R file not running, path ignored

I'm trying to make helloworld.R run. I have given it executable rights and have added #!/usr/bin/Rscript at the top of the file. (I have also attempted #!/usr/bin/en Rscript). It is a relatively simple file: #!/usr/bin/Rscript x <- rnorm(100) df <-…
Frank Vel
  • 1,202
  • 1
  • 13
  • 27
4
votes
2 answers

Multi-Line Rscript in Dockerfile

I am trying to build a docker image with R, and I'd like to be able to break out my package install steps in a clean, easy to read, manner across multiple lines, but bash does not seem to like the approach due to not knowing where the ending )…
petergensler
  • 342
  • 2
  • 8
  • 23
4
votes
1 answer

How to get exit status of R script run in shell script

Suppose I'm running a Rscript from inside this shell script #!/bin/bash RES=$(./abc.R 100) r_status=echo $? There is some code in abc.R which stops its execution #!/usr/bin/env Rscript ... ... if(nrow(status) == 0) { stop("The list id is not…
Avinash Sonee
  • 1,701
  • 2
  • 15
  • 17
4
votes
4 answers

Rscript execution error: No such file or directory

The binary of Rscript is available but when I try to use it I get: Rscript helloworld.r Rscript execution error: No such file or directory If I just do Rscript, it brings the help/usage for it through. R CMD BATCH is working fine. I tried adding…
Sourabh Potnis
  • 1,431
  • 1
  • 17
  • 26