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

R CVXR matrix multiplication %*% Error in mul_dims_promote(lh_dim, rh_dim) : Incompatible dimensions

Hello I am trying to run the example from here: http://rtutorial.altervista.org/lp_solvers.html A snippet and test where it goes wrong: library(CVXR) #create Variable objects that can be manipulated by the solver. x<-Variable(3) #coefficients for…
Greg Nowak
  • 68
  • 5
2
votes
3 answers

Parsing a text file by a delimiter and outputting multiple files with R

I’m trying to break down my server-log into multiple files so I can run some metrics on them. I have this cronjob that adds a string and a timestamp to my server-log at the first of every month, the string looks like this ‘Monthly Breakpoint, March…
MostlyRquestions
  • 526
  • 2
  • 7
  • 22
2
votes
4 answers

Optimize calls to mutate and summarise?

I have this R script: rm(list = ls()) library(tidyr) suppressWarnings(library(dplyr)) outFile = "zFinal.lua" cat("\014\n") cat(file = outFile, sep = "") filea <- read.csv("csva.csv", strip.white = TRUE) fileb <- read.csv("csvb.csv", strip.white…
Jstation
  • 407
  • 4
  • 14
2
votes
1 answer

How to change the shape of a data frame in R? (stacking columns with the same names together)

I'm trying to reshape a data frame in R: Gene_ID Value Gene_ID.1 Value.1 Gene_ID.2 Value.2 1 A 0 A 3 A 1 2 B 5 B 6 B 5 3 C 7 C 2 C …
a.sandra
  • 21
  • 3
2
votes
3 answers

How to get an Rscript to return a status code in non-interactive bash mode

I am trying to get the status code out of an Rscript run in an non-interactive way in the form of a bash script. This step is part of larger data processing cycle that involves db2 scripts among other things. So I have the following contents in a…
S2850951
  • 182
  • 8
2
votes
0 answers

SparkR: source() other R files in an R Script when running spark-submit

I'm new to Spark and newer to R, and am trying to figure out how to 'include' other R-scripts when running spark-submit. Say I have the following R script which "sources" another R script: main.R source("sub/fun.R") mult(4, 2) The second R script…
Joe J
  • 9,985
  • 16
  • 68
  • 100
2
votes
1 answer

Install.packages installs source in Rstudio console but binary when using Rscript

I am working on a package that supports interaction with an alternatively shaped library structure which supports installing multiple versions of a package in parallel (RVClibrary, soon on CRAN). Recently, I met some strange behaviour and I hope…
Siete
  • 328
  • 3
  • 14
2
votes
2 answers

R, STDIN to Rscript

I am trying to make a R script - test.R - that can take either a file or a text string directly from a pipe in unix as in either: file | test.R or: cat Sometext | test.R Tried to follow answers here and here but I am clearly missing something. Is…
user3375672
  • 3,728
  • 9
  • 41
  • 70
2
votes
0 answers

Execute a .R script file from Lua

Is it possible to execute an existing .R script file from within a Lua session? From this helpful page I know that you can access existing R-Sessions and extract objects from it. I also know that you can execute single commands with e. g. local R =…
oepix
  • 151
  • 2
  • 12
2
votes
1 answer

show input as it's executed with Rscript

I have an Rscript that I run using crontab, that take a long time to complete. I'm appending the output of it to a file, and have littered the code with print statements to track the progress of the script as it's running in the background. This…
eddi
  • 49,088
  • 6
  • 104
  • 155
2
votes
3 answers

R code to replace character values in a string starting from the second encounter

I have some input strings in R. Input strings are : abcde, abcdabcd, apapap Output strings should be : abcde, abcdbcde, apbqcr I need R code that does this thing. We should be able to iterate the string, count the number of occurrences of…
Bullu
  • 23
  • 7
2
votes
0 answers

Running R Scripts With Windows Task Scheduler

I am attempting to run a saved R script using Windows Task Scheduler. When I run it it fails. In an attempt to troubleshoot the problem I created a small test R script test <- function(){ print("test") } test() I then create a small bat file…
2
votes
1 answer

R Sys.getenv() returns the wrong value

I am using R in ubuntu. The environment variable value returned is wrong. I had the environment variable set to a value. After a disk crash, I changed its value. However the R will always return the old value. I don't know where R cached the old…
Kemin Zhou
  • 6,264
  • 2
  • 48
  • 56
2
votes
1 answer

no sound from beepr in Rscript

I am trying to use beepr in my Rscripts to tell me when they are done. But the beep never comes. here is an example script saved as test.R: #!/usr/bin/env Rscript library(beepr) beep(1) cat('got here') Then from the terminal I run Rscript…
SamPassmore
  • 1,221
  • 1
  • 12
  • 32
2
votes
1 answer

Won't able to Pass the Table name Dynamically using sp_execute_external_script using R Script

I create this query, This will work fine On SQL Server When am using this query in inside sp_execute_external_script using R Script I won't able to pass '+@TableName+' please check and Suggest some Solution // This code Work fine in SQL Declare…