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

Using Rscript to create graphs from command line

Is it possible to generate PDFs/PNGs of graphs directly from the command line using R? I attempted this with the command: Rscript -e 'pdf(\'Graph.pdf\');plot(c(1,2,3,4,5));dev.off()' which executes, but no file is generated.
Matthew Lueder
  • 953
  • 2
  • 12
  • 25
0
votes
1 answer

Rscript optparse ggplot

I have setup an Rscript to parse options from the command line. It parses the file name fine, but when I try and specify what to plot on the x or y axis by command parsing, it doesnt recognize the field I am trying to plot. Here is the…
0
votes
2 answers

Replace value in data.frame with value in next column

I have dataframe with two columns: names duration 1 J 97 2 G NA 3 H 53 4 A 23 5 E NA 6 D NA 7 C 73 8 F NA 9 B 37 10 I 67 What I want to…
TityBoi
  • 399
  • 1
  • 4
  • 11
0
votes
1 answer

X axis in DateTime format in R script/plot

I am trying to build a forecast plot in R. But, inspite of trying many solutions I am unable to plot my X axis in dates. My data is in the form of : Datetime(MM/DD/YYY) ConsumedSpace 01-01-2015 2488 02-01-2015 7484 03-01-2015 …
0
votes
0 answers

R files run incompletely but without error on Windows server

I have a series of R files on my desktop computer that run daily when triggered by Windows Task Manager. I'm trying to migrate these files over to a server so that they're not dependent on my local machine, but I'm having trouble. The server a…
user3786999
  • 1,037
  • 3
  • 13
  • 24
0
votes
1 answer

Is a cluster computing job an immediate submission or continual access?

I normally do work on a cluster computer. I have a few very large Rscripts that I use to run data. The full Rscript takes about 5 hours to run. To do this, I use the cluster by submitting a job with qsub. This allows me to leave my computer and wait…
Evan
  • 1,477
  • 1
  • 17
  • 34
0
votes
1 answer

igraph and read.table, isolated vertices in R

I saw that igraph in R requires data structured like this: nodeA nodeB int_1 int_2 AA BD 6 X BD CA 8 Y AA DE 7 Y ... ... ... ... And I saw that through…
Marco Pietrosanto
  • 420
  • 1
  • 7
  • 18
0
votes
2 answers

Cannot run " setwd " and " read.csv " in php R script

I try to make WebApp using php & R . this is my php code: exec("/usr/bin/Rscript /home/bella/Downloads/htdocs/laut/script.r $N"); $nocache = rand(); echo(""); And this is my script.r code: slices <- c(10, 12,4, 16,…
0
votes
0 answers

Error in eval(expr, envir, enclos) : could not find function ".getNamespace" and unable to load R code in package

I have a package 'My_Package' in this path /proj/users/Rbud/packrat/lib/x86_64-pc-linux-gnu/3.2.3/My_Package I am trying to exectute an Rscript by scheduling a cronjob. Each time cronjob runs I get the following error Error in eval(expr,…
R Bud
  • 261
  • 1
  • 4
  • 16
0
votes
2 answers

How to run R jobs within a .sh file

I am trying to run an R script. These are some lines from my R script big2.r dataa <- read.csv("/home/people/R2/big2.csv") write.csv(head(dataa), file="/home/people/R2/head.csv") when I execute R CMD BATCH big2.r in the terminal, it gives me an…
andy
  • 643
  • 2
  • 12
  • 20
0
votes
2 answers

How to match the regex for the below pattern?

I am trying to write a script which should work out like this below but somehow am not able to get the write way to put the syntax. I have folders like S_12_O_319_K4me1. While the contents are S_12_O_319_K4me1_S12816.sorted.bam in each folder. So I…
ivivek_ngs
  • 917
  • 3
  • 10
  • 28
0
votes
1 answer

R script plot with ID on xaxis and all column values on yaxis

I am new to R script and need help with plotting the data. My data looks like this run1Seek run2Seek run3Seek 1 12 23 28 2 10 27 0 3 23 19 0 4 22 24 0 5 21 26 …
Twinkling Star
  • 135
  • 2
  • 14
0
votes
1 answer

Rscript - knitr: substr function not working correctly inside knitr code chunk

The following code does not work correctly inside knitr code chunk (it does not extract the desired substring): What might be causing this behavior? #Retrieve the earliest date earlydate <- min(time(month[1]), "2016-04-20") earlydate #Extract…
KK.
  • 693
  • 6
  • 15
0
votes
1 answer

Specifiy version of R to run when running a script from bash

I am trying to run an R script from a bash script using the Rscript command. The cluster I am on has multiple versions of R, and is telling me: "Error: This is R version 2.15.1. Package 'raster' requires >= 3.0.0. Is there a way to specify the…
MikeJewski
  • 357
  • 2
  • 13
0
votes
2 answers

Setting python version from command line

I am trying to run an R script from the command line using Rscript. The R script calls some python code and works fine when run interactively. However, when I call it from Rscript I get some errors with gdal. I believe the errors are related to…
jsta
  • 3,216
  • 25
  • 35