15

In batch script, I can run an R script with the following syntax:

Rterm.exe --quiet --slave --vanilla < "C:\some_script.R"

However, Powershell seems to have reserved "<" for future expansion. I am wondering if there is a direct way to run R script within another Powershell script.

2 Answers 2

26

You should probably look Rscript instead of redirection -- this would become

Rscript.exe C:\someScript.R

where you can add the usual options.

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

1 Comment

For anyone visiting this page now (and I know it's 5 years old), there's a more general answer for running external programs and redirecting stdin to powershell at stackoverflow.com/questions/12478535/… . Clearly though Rscript is a better option than Rterm for this.
4

Easiest way is probably to wrap it in a call to cmd.exe:

cmd.exe /C "Rterm.exe --quiet --slave --vanilla < `"C:\some_script.R`""

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.