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

can use package interactively, but Rscript gives errors

I'm using the "topicmodels" package in R. Everything works fine interactively, but if I run the exact same commands using Rscript, I get errors. The first error (which I solved) is that R didn't know what the is() function was. I solved this by…
a b
  • 171
  • 1
  • 1
  • 10
2
votes
1 answer

R, command line, write to file fails

I am trying to automate (on a Win7 system) an R script to read data from Bloomberg and write it to file, for processing by another system. My code runs in the R gui perfectly. So I wrote a batch file to call this .r file and output results to…
silly_penguin
  • 201
  • 2
  • 5
2
votes
0 answers

How to make Rscript stay open until gWidgets gui is closed

I have a script which launches various gWidgets windows with buttons that have functions attached. I'd like to be able to launch this with rscript.exe so others can use it without seeing R. My problem is that when I launch the script using…
Dean MacGregor
  • 11,847
  • 9
  • 34
  • 72
2
votes
2 answers

R package not found when launch from python under windows 7

I try to run R script via a python GUI. Under R console, I installed the rgl package. In windows-7, R install packages under the current user folder, not the ProgramFiles\R... folder. I have a simple demo.r…
user1520280
  • 665
  • 1
  • 6
  • 8
2
votes
1 answer

How to invoke script that uses scan() on Windows?

How to invoke an R script like the following scan() in Windows? When using either R or Rscript, nothing is read. With Rscript or littler (both on Linux) the script works as expected. # Doesn't work because stdin is already redirected R --no-save <…
krlmlr
  • 25,056
  • 14
  • 120
  • 217
2
votes
2 answers

How to submit an R script to a job scheduler: bash, compiler, Rscript, or other?

My Problem: I have an R script myscript.R that uses a configuration file, e.g. config.xml, what is the best way to submit such a script to a job scheduler (e.g., using qsub)? I would like to be able to use the script and file in the same way that I…
David LeBauer
  • 31,011
  • 31
  • 115
  • 189
1
vote
1 answer

Rscript issue - using different version of R?

I'm trying to load a library in an Rscript, but it's giving me a strange error. I'm running the 2.12.1 version of the Rscript binary, yet it complains that my package was built under version 2.12.1. Any idea what's going on here? [17:55:13…
khoda
  • 355
  • 3
  • 7
1
vote
1 answer

How to fix poor bathymetry resolution using "ggOceanMaps" package in R?

I am using ggOceanMaps in R and I tried to create a map of Southern California with bathymetry data. However, the bathymetry is blurred out, which makes me think the package does not have good bathymetry data to make a close-up map of a given area.…
1
vote
0 answers

error: Penman-Monteith FAO56 Reference Crop ET

I am using the ET.PenmanMonteith function from the Evapotranspiration package in R to calculate reference crop evapotranspiration. I have provided the necessary input data, including daily dates, temperature (Tmax, Tmin), relative humidity (RHmax,…
1
vote
0 answers

Can the R package configure and configure.win scripts be run interactively?

Is there a way to accept user input when running R CMD INSTALL PATH_TO_SRC.tar.gz? This is for a private R package where I'd like to have the user accept a EULA before the installation completes. I was attempting to accomplish this using the…
esiegel
  • 1,773
  • 2
  • 19
  • 31
1
vote
1 answer

How can I get /usr/bin/time to recognize my R environment?

I am trying to measure the peak memory usage of an R script using /usr/bin/time. The following code works fine: Rscript testMemoryUsage.R as does: time Rscript testMemoryUsage.R However, the following doesn't work: /usr/bin/time Rscript…
David_G
  • 77
  • 4
1
vote
1 answer

Sys.getenv in R

cur_dir<-"C:/Users/child/Dropbox/Proteogenomics_analysis/Proteome and Phosphoproteome Data Normalization/Experiment_data_20230222_Metabric_multistate_analysis" setwd(cur_dir) library(mstate) library(brcarepred) id <-…
김태훈
  • 13
  • 2
1
vote
0 answers

Running R script from Java using Runtime rt = Runtime.getRuntime(), RScript, and Buffered reader seems to hang before finishing

I am running an R script from java using RScript and Runtime.getRuntime() as shown in the code below. The code seems to stop part way through (the code stops writing output). If I run the script from a cmd line the script runs to completion. I'm…
John
  • 3,458
  • 4
  • 33
  • 54
1
vote
2 answers

How can I copy and rename a bunch of variables at once?

I have created some variables. I would like to duplicate these so that they exist twice, once with the name you see below, and once with Ireland_ in front of their name, i.e., c_PFS_Folfox = 307.81 would become: Ireland_c_PFS_Folfox = 307.81 I…
1
vote
1 answer

R Studio will not open .r files in source

I have used R for years and, until recently, have had few problems. However, since the last update, R keeps erasing scripts that I have saved in the Source window; then, when I go to retrieve them from recent files, it opens a script that has a…