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

Including Command Line Scripts with an R Package

I am interested in providing a command line interface to an R package called Slidify that I am authoring. It uses Rscript and I think that would make it cross-platform. The scripts are stored in the subdirectory inst/slidify. In order to use the…
Ramnath
  • 54,439
  • 16
  • 125
  • 152
11
votes
4 answers

Rscript on ubuntu

Where can I install Rscript from? I need to run an R script from a php file using exec. However I need to install Rscript first.
jkjk
  • 5,777
  • 4
  • 20
  • 19
11
votes
2 answers

readLines function with new version of R

My function is: create_matrix <- function() { cat("Write the numbers of vertices: ") user_input <- readLines("stdin", n=1) user_input <- as.numeric(user_input) print(user_input) } With the version 3.5.0, after i entered the data the…
Dr.mincode
  • 121
  • 5
11
votes
1 answer

setClass not found when running R script from command line

I have simple R script which trying to Define class. example.R Tuple <- setClass("Tuple", slots = c( id="character", comp="character", stream="character", …
user2862709
  • 153
  • 1
  • 6
11
votes
1 answer

Using Rscript, is there a decent way to suppress the non-script output?

Possible Duplicate: R suppress startupMessages from dependency I've read about using sink("NUL") / sink("/dev/null"), but neither of them has fixed the problem I'm having. Even if I wrap the library() commands in sink("NUL") and sink(), my call…
Claire Sannier
  • 902
  • 2
  • 8
  • 19
9
votes
2 answers

File path with Unicode characters in Rscript.exe

I'm trying to save an SVG image to a file path containing Unicode characters. For example: n = c(2, 3, 5) s = c("aa", "bb", "cc") b = c(TRUE, FALSE, TRUE) df = data.frame(n, s, b) svg("c:/נועם/plots.svg") plot(df) dev.off() Running this with…
Noam Behar
  • 201
  • 2
  • 11
9
votes
3 answers

Rscript in silent mode

I am using Rscript to run an R script but I get a lot of output on my screen. Can I run Rscript in silent mode (meaning without any screen output)?
averageman
  • 893
  • 3
  • 12
  • 19
8
votes
1 answer

How can I pass arguments to an Rscript i have in my desktop?

I have a rscript (file.r) in my desktop which contains a function. I need to call this function from Windows command prompt and pass arguments to it, I have found this way but i don't understand how it's used, like what does it mean? I already have…
Ayer Alobaid
  • 123
  • 1
  • 1
  • 6
8
votes
2 answers

Run R interactively from Rscript

I'm trying to start a shiny app or an interactive .Rmd document from an Rscript. However, all I get is a message Listening on http://127.0.0.1:... I believe this is because R is running in interactive mode (another post about this). How can I…
Rorschach
  • 31,301
  • 5
  • 78
  • 129
7
votes
1 answer

Cannot call roxygenize function from Rscript batch file

I am writing a script that uses roxygen2 to automatically roxygenize my package. I'd like it to be executable so that it can be part of a larger script to prepare and install the package, but I cannot make it work with Rscript for some reason. Here…
Erik Shilts
  • 4,389
  • 2
  • 26
  • 51
7
votes
4 answers

Leaving RScript-produced plots on screen until user interaction

I have have a R script which queries a database, runs some analysis, plots a few charts based on the current system date. I want to get this script to run daily at boot, I thought I could do this fairly simply using a shortcut to rscript.exe with…
BetaScoo8
  • 429
  • 4
  • 9
7
votes
1 answer

How to make datatable editable in R shiny

I am creating R shiny app, I am not sure how to make my datatable editable of rows and columns in R shiny. As I tried using renderDT=(editable = TRUE) from the package DT, but it didn't work. Could someone please show me how to do this in R…
Kevin Tracey
  • 154
  • 1
  • 16
7
votes
4 answers

zsh: command not found: R on terminal using Big Sur Mac

I installed R from official cran website and i can run R from the Rstudio but when i try to use R from the terminal, I get the following results: (base) ege@Eges-MBP ~ % R zsh: command not found: R (base) ege@Eges-MBP ~ % RScript zsh: command not…
Ege Can
  • 195
  • 1
  • 10
7
votes
1 answer

R and Rscript give different results for datetime

When I try to execute the following code on RStudio library(lubridate) library(data.table) a <- data.frame(c("2017-12-01 00:01:00","2017-12-02 00:01:00"),c(5,6)) colnames(a) <- c("t", "x") a <- as.data.table(a) a[, t := parse_date_time(t, orders =…
7
votes
1 answer

call R script from Shiny App

I developed a shiny app which displays some dynamic charts. These charts are generated at execution time according to the value of some buttons. This shiny app gets the data from a raw csv which is previously treated and transformed. I got a Rscript…
Luis Cano
  • 97
  • 1
  • 1
  • 6
1
2
3
43 44