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
1
vote
0 answers

Rscript called with crontab not finding local packages

I have the following R script ~/test.R : print(.libPaths()) print(system(command = "whoami",ignore.stderr = TRUE)) library(lubridate) ymd("2022-09-15") If I run this script from the terminal with /opt/R/3.6.2/lib64/R/bin/Rscript test.R > test2.log…
Augustin
  • 307
  • 2
  • 10
1
vote
1 answer

ggplot heatmap: different hues for different categories by rows

I'm trying to create a heatmap showing monthly fruit abundance of various species at three different sites (C, G, N). I'd like each site to be represented by a different colour (C = grey, G = yellow, N = blue) and abundance represented by the shade…
njc
  • 21
  • 3
1
vote
1 answer

Finding if my function inside an rscript file is been called by either an rmarkdown or an rscript

I have a function in an Rscript (this is inside an r-package of my own) that is been called either by an .R(Rscript) file or an .Rmd(rmarkdown). I need to create an if statement inside this function to do things depending if the function is called…
miyene
  • 41
  • 7
1
vote
1 answer

Issues when using logger package in r-markdown when initializing log_errors()

I created a function to initialize logging using logger package and to save the logs entries in a temporary file in the tempdir() given by R. init_logger <- function() { library(logger) temporary_directory <- tempdir() date_time_current <-…
miyene
  • 41
  • 7
1
vote
0 answers

Escape Special Character in output-path of rmarkdown::render()

I'm currently working on multiple reports that I generate with rmarkdown::render(). I use a Main.Rmd as a template to create the report for a certain group. In an R.Script-File I use a loop to iterate over the groups (and their subgroups) and render…
Martina
  • 139
  • 1
  • 10
1
vote
0 answers

How to fix Error in BatchGetSymbol download?

I Have been using batchgetsymbol for months without any issues but today I constantly receive "error in download". Here's my original R script: us.data7 <- BatchGetSymbols(tickers =…
1
vote
0 answers

using the windows-cmd to start the RGTK2 based GUI

I would like to use the windows-cmd to start R code that was a GUI depending on RGTK2. For example , named mycode.R library(RGtk2) library(gWidgets2) library(gWidgets2RGtk2) G.window <- gwindow() this code can be done in the R and…
Hees
  • 111
  • 1
  • 9
1
vote
0 answers

how to pause an R script until cmd prompt is running?

How can I assign with in Rscript to pause until the command prompt is open? I am running a Rscript where a batch file will be executed through command prompt. Later I want to copy a product of executed batch file to another folder. However, Rscript…
Arun Bawa
  • 13
  • 3
1
vote
0 answers

RODBC connection works in RStudio but not in prompt, stuck with architecture incompatibility issue

I'm trying to exec a R script with a prompt command but I'm struggling with compatibility issues and I can't find the proper way to achieve this. I'm on Windows x64, I have a x32 DSN that works perfectly when the R script is executed in x64 RStudio…
Stripote
  • 11
  • 2
1
vote
0 answers

R error: file does not exist in current working directory how to troubleshoot RScript & RMarkdown communication issues?

I'm new to R and I'm having trouble transferring an analysis in an R Script file to an R Markdown file. I'm using a MacBook Pro so my working directory right now is my default computer folder with my first&last name. When I use the import dataset…
1
vote
0 answers

Table in the Rmarkdown file does not render correctly (via RScript)

I am trying generate automated reports using rmarkdown, and final output expected is pdf. However, when I run the script the resulting .Rmd file is okay, but the resulting .pdf file does not show the table. It just shows the table as a list of…
Sam
  • 7,922
  • 16
  • 47
  • 62
1
vote
1 answer

R code works in script but not R markdown

#The code below works fine in my scripts but not in R markdown. library(tidyverse) library(scales) age <- kaggle_2020_Survey %>% transmute(Q1 = as.factor(Q1)) %>% filter(!is.na(Q1)) %>% count(Q1) %>% mutate(perc =…
Rizzle
  • 117
  • 6
1
vote
0 answers

Running R from VBA and seeing what's going on in the background

When I run an R script from VBA, a command prompt window is opening but no messages are appearing with information about the steps the Rscript is taking. When I run the Rscript in RStudio or the R console, those messages are appearing, but that's…
1
vote
1 answer

How to generate a new column and fill the values if the particular columns values in CSV A and CSV B match?

I am working on R Programming, where there are 2 CSV files containing the below data. My program should work if the values of Shipping_ID(CSV_A) and Customer_ID(CSV_B) matches. The CSV_A should create an extra column named 'New Column' and that…
Kevin Tracey
  • 154
  • 1
  • 16
1
vote
0 answers

Using R keyring library in batch Rscript produces "key is not a string (length 1 character)" error

The following R script running on RHEL 7.7 is producing a "key is not a string (length 1 character)" error when executed from the command line using RScript. The password was successfully set within the R environment using…