Running an R script using a Windows shortcut

后端 未结 4 1799
星月不相逢
星月不相逢 2020-12-16 21:14

I am trying to create an icon on my desktop (Windows OS). By clicking on this icon, an R script will be executed, which launches a GUI application (gWidgets).

相关标签:
4条回答
  • 2020-12-16 21:51

    Read the help file ?Startup for details on what R goes through in the startup process and how you can automate running code.

    I have done things like this for clients where I create a GUI for a specific demonstration (I use tcltk, but all should work the same). I created a desktop shortcut for them and modified the shortcut to start in a specific folder (but run the standard Rgui program), then in that folder I save a .Rdata file with all the code and data that the demo needs along with a function named .First that starts the demo.

    Then the client does not need to know anything about R, just double click the shortcut and R starts and my demo starts automatically for them, they enter some numbers, click some options, slide some sliders, etc. and click on "OK" to see a graph or other output customized to their situation.

    0 讨论(0)
  • 2020-12-16 22:07

    A basic version of this I've done in Windows 7 is;

    1. locate RScript.exe (e.g. C:\Users\USERNAME\Documents\R\R-3.3.2\bin\x64\RScript.exe)
    2. right click and select 'Pin to Taskbar'

    The R icon should appear on the taskbar at the bottom of your screen

    1. find your script (e.g. C:\Users\USERNAME\Documents\MyScript.R) and drag this onto the R icon on the taskbar
    2. right-click the icon, 'MyScript' should be pinned there.
    3. click 'MyScript' to run the script.
    0 讨论(0)
  • 2020-12-16 22:11

    I think your looking for a batch file to launch a file ?

    if so check this out, this comment lists how to do it in command prompt, turn that into a batch file.

    https://stat.ethz.ch/pipermail/r-help/2002-March/019950.html

    0 讨论(0)
  • 2020-12-16 22:11

    Have you tried using the RScript command? I don't know how it works on Windows, but in Linux I would do something like:

    Rscript --vanilla -e 'source("abc.R")'
    
    0 讨论(0)
提交回复
热议问题