Skip to content

run R script automatically by double-clicking WinXP desktop icon

4 messages · Cedrick Johnson, Christopher W. Ryan, Franzini, Gabriele [Nervianoms]

#
I've written a simple script that does some surveillance analysis on daily counts of walk-in clinic visits, for our county health department. (Actually, Michael Hohle's surveillance package does all the work; I just customized it a little to work with the way our data are recorded.) The output consists of a graph and a little table.

My colleague will run it once in a while, on continuously updated data. She knows nothing about R, at least not yet. I want to make it as simple as possible. Rather than have her open R and type source("filename"), I want to be able to put an icon on her WinXP desktop, so that when she double-clicks it, R will open, run the script, and up pops the graph.

I've been trying to learn about R CMD BATCH, playing with the dialogue boxes for WinXP desktop shortcuts, etc, but no luck so far. I guess I don't know enough about Windows.

Can anyone tell me how to do this?  Thanks.

--Chris Ryan
#
Here's something I use (in a batch file):

Rterm --no-restore --file=EveningStartup.r


Change EveningStartup.r to your particular file. When you create the 
shortcut, make sure to set the working directory to where your R script 
is located. Then in your file, you could have the graphs write out to a 
png file in a specified directory.

hth
c
cryan at binghamton.edu wrote:
#
that helps, thanks. I can put a final line in my batch file that opens a viewer for the png graph. 

I was hoping to find a way to do make it run in the Rgui (picky, I know.) My graph is clearer in the default graph device that pops up in the Rgui; it's blurry in the Windows viewer for png files. I should probably play around with the resolution in R's png device. Or maybe it's a function of the viewer I'm stuck using.

Thanks.

--Chris 

---- Original message ----
#
Hello Chris,
I had the same problem, and I ended up driving R Gui through an Autoit
script, see http://www.autoitscript.com/autoit3/ Regards,
Gabriele Franzini


-----Original Message-----
From: cryan at binghamton.edu [mailto:cryan at binghamton.edu] 
Sent: 22 September 2009 19:37
To: r-help at r-project.org
Subject: Re: [R] run R script automatically by double-clicking WinXP
desktopicon

that helps, thanks. I can put a final line in my batch file that opens a
viewer for the png graph. 

I was hoping to find a way to do make it run in the Rgui (picky, I
know.) My graph is clearer in the default graph device that pops up in
the Rgui; it's blurry in the Windows viewer for png files. I should
probably play around with the resolution in R's png device. Or maybe
it's a function of the viewer I'm stuck using.

Thanks.

--Chris 

---- Original message ----
daily counts of walk-in clinic visits, for our county health department.
(Actually, Michael Hohle's surveillance package does all the work; I
just customized it a little to work with the way our data are recorded.)
The output consists of a graph and a little table.
data. She knows nothing about R, at least not yet. I want to make it as
simple as possible. Rather than have her open R and type
source("filename"), I want to be able to put an icon on her WinXP
desktop, so that when she double-clicks it, R will open, run the script,
and up pops the graph.
dialogue boxes for WinXP desktop shortcuts, etc, but no luck so far. I
guess I don't know enough about Windows.