3

I have created a Windows 7 shortcut in an attempt to give someone who is not comfortable with R the ability to run a simple program. I have tried to follow the advice of other postings, but must be missing something. This is what I have in my shortcut right now.

Target: "C:\Program Files\R\R-3.0.2\bin\x64\Rscript.exe" --vanilla -e "C:\Users\Moo\Desktop\CharCalendar.r"

Start in: "C:\Program Files\R\R-3.0.2\bin\x64"

I get error messages (that flash up very briefly on a black DOS window) that say things like Error unexpected input in "C:\"

I have tried with and without quotes in the target, I have tried using source() in the target (also with and without quotes).

The script runs without error when I submit it in the R console.

Jean V. Adams
  • 4,634
  • 2
  • 29
  • 46

3 Answers3

3

You probably want

"C:\Program Files\R\R-3.0.2\bin\x64\Rscript.exe" --vanilla C:\Users\Moo\Desktop\CharCalendar.r

as your target. No -e; that specifies an expression to run, not a script file.

Hong Ooi
  • 56,353
  • 13
  • 134
  • 187
0

I must admit, I hardly ever made my own shortcut in Windows. However, you coul seemly write a bat-file which runs the R-script and PAUSES, so you can read the output:

@echo off
"C:\Program Files\R\R-3.0.2\bin\x64\Rscript.exe" "C:\Users\Moo\Desktop\CharCalendar.r"
PAUSE

You may also want to add additional options and arguments after Rscript.exe. If you want to pass it to Rgui.exe, it will be a trickier. Read the following stackoverflow-topic for hints:

Passing script as parameter to RGui

Community
  • 1
  • 1
Florian R. Klein
  • 1,375
  • 2
  • 15
  • 32
0

Replace Rscript.exe -e with Rterm.exe -f, which indicates that you are passing a file as argument, -e is for passing expressions e.g. Rscript.exe -e "a<-1:10; mean(a);" Rterm provides a few more options for control compared to Rscript, see Rterm.exe --help.

ndr
  • 1,427
  • 10
  • 11