Home > Enterprise >  clic button to launch r script
clic button to launch r script

Time:08-25

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:

  1. Create your R script. Mine is ~/StackOverflow/19091739/73472411.R, and it contains these contents:

    message("hello world")
    Sys.sleep(10)
    
  2. Right-click on the Windows desktop, and select New >> Shortcut.

  3. Type in the path to your R executable, but use Rscript.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!

  •  Tags:  
  • r
  • Related