I would like to create a run button for my Rstudio script on my desktop so that when I double click on the button my script launches, but I'm struggling a bit. Do you have any ideas please?
CodePudding user response:
Create your R script. Mine is
~/StackOverflow/19091739/73472411.R
, and it contains these contents:message("hello world") Sys.sleep(10)
Right-click on the Windows desktop, and select New >> Shortcut.
Type in the path to your
R
executable, but useRscript.exe
instead. Add to that your filename. Mine looks like this:C:\R\R-4.1.2\bin\Rscript.exe c:\Users\r2\StackOverflow\19091739\73472411.R
Note that if there are spaces anywhere, you'll need to quote the path(s) appropriately.
This creates a shortcut icon on the desktop that, when pressed, opens a non-interactive R session, displays "hello world", waits 10 seconds, then exits/disappears.
CodePudding user response:
very good! I tried it and it worked. thanks!