Running an R script using a Windows shortcut

匿名 (未验证) 提交于 2019-12-03 01:48:02

问题:

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).

回答1:

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.



回答2:

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



回答3:

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")'


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!