Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leaving RScript-produced plots on screen until user interaction

Tags:

windows

r

rscript

I have have a R script which queries a database, runs some analysis, plots a few charts based on the current system date.

I want to get this script to run daily at boot, I thought I could do this fairly simply using a shortcut to rscript.exe with necessary parameters.

This works fine, however the script quits after it is run, not very useful for viewing the charts.

I'm using XP and win7.

Is there an easy way to keep the output from the script on screen? I've tried incorporating scan into the script, but it doesn't pause.

I know I could just open the rgui, and run a single line of code, but the plan is to deploy this to a colleague's computer who is totally unfamiliar with R.

like image 933
BetaScoo8 Avatar asked Nov 17 '11 13:11

BetaScoo8


1 Answers

This works for me on Linux:

#!/usr/bin/env Rscript

X11()
with(mtcars, plot(mpg, hp))
locator(1)

The user has to click the plot window before it disappears. I presume it would work on Windows with a call to windows() instead.

like image 177
Michael Hoffman Avatar answered Nov 05 '22 02:11

Michael Hoffman