defoo
defoo

Reputation: 5297

Run R script from Powershell

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.

Upvotes: 15

Views: 30254

Answers (2)

Dirk is no longer here
Dirk is no longer here

Reputation: 368201

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

Rscript.exe C:\someScript.R

where you can add the usual options.

Upvotes: 25

James Kolpack
James Kolpack

Reputation: 9382

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`""

Upvotes: 4

Related Questions