2

I want to execute a R script from a python script using:

subprocess.call("Rscript script.R --args arg1 arg2", shell=True)

How do I have to write my script.R in order to use the args?

1 Answer 1

0

Using commandArgs like this:

args <- commandArgs(trailingOnly = TRUE)

arg1 <- args[1]
arg2 <- args[2]
[...your code...]

Also make sure that the Rscript executable is in your PATH.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.