R.exe, Rcmd.exe, Rscript.exe and Rterm.exe: what's the difference?
Caveat: I work much more on Linux than Windows:
Rcmd.exe
is a historical left-over as back in the day, you could not doR CMD something
on Windows but needed the special executableRcmd.exe something
. That is no longer the case, yet it is provided for backwards compatibility.Rterm.exe
is also a holdover from the days whenRcmd.exe
was used. Can be ignored these days.R CMD BATCH
is a crutch that was needed in the days before littler andRscript.exe
, and similarly lingering from old docs and habits..Rscript.exe
is your friend for batch scripts; use it.- For everything else, there's
R.exe
.
Other than that, as Marek hinted, the reference manual is the wrong one among the six available manuals. Try the Introduction to R and the Installation and Admin manuals both of which have specific appendices for Windows.
R platform failed to start in Windows 10 when inside directory containing white spaces
In the end, I found a plausible solution by myself.
I realized that every time the R.exe is executed in a directory without spaces, the execution is automatically redirected to Rterm.exe. I don't know if they fixed the bug specifically to Rterm.exe in the last version, but this suggests that the Rterm executable is the responsible for opening the R console, and when I tried to execute it directly through a spaces-containing directory, it worked fine (at least in the last R version).
So, in summary, if someone else had this problem, just run Rterm.exe directly.
This resolution is useful enough for those who just depend on R portability, although the Rscript.exe and R.exe still are not working in these conditions. Rscript.exe is useful to execute scripts directly without the need to manually start a new session in a new window, and R.exe redirects to Rterm.exe based on your system, if it is 32-bit or 64-bit (at least as I observed).
Anyway, I already informed CRAN project about this bug, and I hope they check it and fix the issue in the next version. If someone else found an alternative solution, feel free to comment.
Why does running shiny start two Rscript processes on windows when launching from cmd line?
This is a general thing with the R scripting command-line utilities (Rscript.exe
, R.exe
, Rcmd.exe
) and not specific to Shiny. All of these actually call Rterm.exe
underneath to run the actual program in a separate process.
Try Rscript.exe
with --verbose
and you'll see what I mean:
> Rscript --verbose script.R
running
'C:\PROGRA~1\R\R-34~1.0\bin\x64\Rterm.exe --slave --no-restore --file=script.R'
You can try out the other tools and see how they behave.
For more info, check out the source code
- https://github.com/wch/r-source/blob/trunk/src/gnuwin32/front-ends
- https://github.com/wch/r-source/blob/trunk/src/unix/Rscript.c
This question has some good info as well
- R.exe, Rcmd.exe, Rscript.exe and Rterm.exe: what's the difference?
Running an R script from command line (to execute from python)
You probably already have R, since you can already run your script.
All you have to do is find its binaries (the Rscript.exe file).
Then open windows command line ([cmd] + [R] > type in : "cmd" > [enter])
Enter the full path to R.exe, followed by the full path to your script.
Related Topics
Posix Character Class Does Not Work in Base R Regex
Check Existence of Directory and Create If Doesn't Exist
Trimming a Huge (3.5 Gb) CSV File to Read into R
Removing Empty Rows of a Data File in R
Omit Rows Containing Specific Column of Na
How to Sum a Numeric List Elements
Sample from Vector of Varying Length (Including 1)
Detect At Least One Match Between Each Data Frame Row and Values in Vector
How to Suppress Warnings Globally in an R Script
Difference: "Compile Pdf" Button in Rstudio Vs. Knit() and Knit2Pdf()
Faster Way to Read Fixed-Width Files
R Stacked Percentage Bar Plot With Percentage of Binary Factor and Labels (With Ggplot)
Access Variable Value Where the Name of Variable Is Stored in a String
Select Subset of Columns in Data.Table R
Assign Multiple Objects to .Globalenv from Within a Function