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

Plots working in R environment, but not through RScript

can anyone explain why if I run this from the command line: >R #So I'm in the R environment >plot(cars) >sessionInfo() The plot is produced as expected and the output from sessionInfo is: > sessionInfo() R version 3.2.3 (2015-12-10) Platform:…
user1288515
  • 195
  • 1
  • 10
3
votes
0 answers

How to pass command line arguments to R script as key value pair

I want to pass command line arguments to Rscript as key-value pair instead of values. Currently I am calling as below Rscript myrscript.R 10 20 I would like to call something as below Rscript myrscript.R a=10 b=20 And finally how can read these…
Teja Varma
  • 31
  • 2
3
votes
3 answers

Rscript not working with packaged R for AWS Lambda

I'm trying to run an R script on the command line of an AWS EC2 instance using packaged R binaries and libraries (without installation) -- the point is to test the script for deployment to AWS Lambda. I followed these instructions. The…
3
votes
1 answer

Add brackets to string in data frame

I've got this data frame called df: ColumnA ColumnB String1 A String2 A String3 B String4 A ... ... Every string in ColumnA have different lenght. I want to put values from ColumnA in brackets if value in ColumnB == A in the same…
TityBoi
  • 399
  • 1
  • 4
  • 11
3
votes
0 answers

How to add input output ports in Microsoft Azure while publishing webservice

I have to publish webservice using Microsoft azure, where my packages are installed and my R script is running but when I click on publish as webservice it gives me error saying that "The ports selected for input and output are not valid."
3
votes
1 answer

How to make executable file from R Project that developed in RStudio?

I desperately want to ask how to create an executable file from R Project that contains some R scripts in RStudio? It doesn't matter that we have to install R first. It doesn't matter whether it .exe or .bat etc. I have been made the GUI with tcltk…
3
votes
0 answers

Error: ReadItem: unknown type 32, perhaps written by later version of R

am running a R script through cron for example R CMD BATCH myRFILE.R myOutFILE.Rout . When i run this from bash it runs successfully , however when i do this through cron for multiple R files i get the following error : Error: ReadItem: unknown…
Sushil Ks
  • 403
  • 2
  • 10
  • 18
3
votes
1 answer

Error in library(optparse) : there is no package called ‘optparse’

I'm trying to run some demo R code for the optparse package that I got from R-bloggers. I am using ubuntu 14.04 The code is: #!/usr/bin/env Rscript library(optparse) option_list = list( make_option(c("-f", "--file"), …
haffamoto
  • 66
  • 1
  • 9
3
votes
1 answer

Running a .vbs script through R, scheduled in Task Scheduler

I have a VBS script that takes an Excel file and saves it as a PDF. I call this vbs as within an RScript that is automated through Task Scheduler. The RScript runs just fine when I run it in R manually. However, when I have it scheduled in Task…
GreenboyCJ
  • 33
  • 4
3
votes
2 answers

Running R script with RSript doesn't seem to save workspace

I am running RSCript with the --save command. When the script finishes, if I then run 'R' I do not workspace variables of script. What am I missing? Thanks.
CptanPanic
  • 828
  • 2
  • 10
  • 19
3
votes
0 answers

Rscript pointing to incorrect R version in local build

I recently installed a local version of R 3.1.0 on a Linux Redhat server as follows: # from R-3.1.0 directory ./configure --prefix=$(pwd) make make install In addition, I've updated PATH and R_LIBS in my .bashrc. If I run…
machow
  • 1,034
  • 1
  • 10
  • 16
3
votes
1 answer

How can I produce wig files from .sam files using a faster R script?

I have an R script in which I can read the lines from a .sam file after mapping and I want to parse lines of sam file into strings in order to be easier to manipulate them and create the wig files that I want or to calculate the cov3 and cov5 that I…
user3683485
  • 115
  • 1
  • 8
3
votes
3 answers

Error installing ggplot2

I was trying to run a simple code on ggplot2 and got the following error: source("u1.txt") Error in library(ggplot2) : there is no package called ‘ggplot2’ Error : package ‘foreign’ was built before R 3.0.0: please re-install it ERROR: lazy…
user1036865
  • 31
  • 1
  • 3
3
votes
0 answers

JRI - Checking for type of returned value from R script

I am using JRI and calling R script from Java. The R script returns an integer. Following is how I am calling the R script - REXP result = rengine.eval("source(\"" + [script name with path] + "\")"); REXP retVal =…
3
votes
2 answers

Running R script through qsub

I am trying to run an R script called test.r through qsub. My R script is as follows: #!/usr/bin/Rscript x <- 1 write.csv(x,"test.csv") If in Ubuntu terminal I type R CMD BATCH test.r, then the script behaves as planned; test.csv gets exported in…
user2763361
  • 3,789
  • 11
  • 45
  • 81