rscript

Python subprocess FileNotFoundError

纵然是瞬间 提交于 2021-02-10 13:43:44
问题 I am trying to follow this blog on how to execute an R script from Python. I have the R script working fine from the command line using Rscript. Here's my Python code: import subprocess import os command = "C:\Program Files\R\R-3.4.4\bin\Rscript" path2script = os.getcwd() + "\max.R" # gives me the absolute path to the R script args = ["11", "3", "9", "42"] cmd = [command, path2script] + args x = subprocess.check_output(cmd, universal_newlines = True) Which gives me this error:

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

谁都会走 提交于 2020-12-15 06:17:12
问题 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 script sample.sh: Rscript --verbose --no-restore --no-save /home/R/scripts/sample.r >> sample.rout when this sample.sh is run it always returns a status code of 0, irrespective of if the sample.r script run fully or error out in an intermediate step.

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

爱⌒轻易说出口 提交于 2020-04-14 11:52:46
问题 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 objective function C<-c(2,4,3) #problem: C %*% x Error: Error in mul_dims_promote(lh_dim, rh_dim) : Incompatible dimensions > x [1] "Variable((3, 1), nonneg=FALSE, nonpos=FALSE, pos=FALSE, neg=FALSE, complex=FALSE, imag=FALSE, symmetric=FALSE, diag

Cannot call roxygenize function from Rscript batch file

微笑、不失礼 提交于 2020-02-02 01:29:13
问题 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 is the code: #!/usr/bin/env Rscript library(roxygen2) roxygenize('.', copy=FALSE) This works correctly if I start an interactive R session or if I submit the code using R CMD BATCH. However, I get this output and error if I run the script directly

Cannot call roxygenize function from Rscript batch file

爷,独闯天下 提交于 2020-02-02 01:29:12
问题 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 is the code: #!/usr/bin/env Rscript library(roxygen2) roxygenize('.', copy=FALSE) This works correctly if I start an interactive R session or if I submit the code using R CMD BATCH. However, I get this output and error if I run the script directly