R: Creating a shortcut to run a <rook app> ?!

269 views
Skip to first unread message

Tal Galili

unread,
Jun 18, 2012, 1:10:11 PM6/18/12
to rr...@googlegroups.com
Hello dear rook useRs,

Suggesting how to Creating a shortcut to run a gWidgets GUI, and wondered if any of you found a solution for doing this with a rook application.  
I suspect the solution proposed in the post might be also used for rook.

Any thoughts?

Best,
Tal

----------------Contact Details:-------------------------------------------------------
Contact me: Tal.G...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English)
----------------------------------------------------------------------------------------------


jverzani

unread,
Jun 18, 2012, 3:35:42 PM6/18/12
to rr...@googlegroups.com
Hi Tal,

To serve a page, one just needs to start R, start Rook, load the app then point a browser to right url.

From within an R session one just has to call `load_app("scriptname.R")`. This will call browseURL to open the script. Alternatively, one can pass in the argument `open_page=FALSE` and then point your browser to http://localhost:PORT/custom/scriptname

There is a file Rook.sh (https://github.com/jverzani/gWidgetsWWW2/blob/master/inst/nginx/Rook.sh) to start R and Rook to run a script from the command line, not from within an R session. This script is modified from Start.sh that Jeff wrote https://gist.github.com/6d09536d871c1a648a84

To create a desktop shortcut would require executing the commands in Rook.sh from shortcut.

Hope that helps. --John

Tal Galili

unread,
Jun 18, 2012, 3:40:27 PM6/18/12
to rr...@googlegroups.com
Hello dear John,
I enjoyed meeting you at useR this year, and attending your talk.

Thank you for your comments.  Please notice how all the solution you provided (correct me if I am wrong), are either for people able to use the R console, or for Linux users (e.g: the .sh solution)
What I am looking for is a way for a naive windows user to use the app.  So something like a shortcut that will start R in a hidden mode, and than run some script (which will obviously run browseURL).
I suspect the link I gave offers such solution, but I didn't try it out yet - and am hoping to hear comments on this topic for windows users.

With regards,
Tal


----------------Contact Details:-------------------------------------------------------
Contact me: Tal.G...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English)
----------------------------------------------------------------------------------------------




Sven Hartenstein

unread,
Jun 19, 2012, 12:41:02 PM6/19/12
to rr...@googlegroups.com
Hi Tal and all,

> I just came across this post:
> http://www.r-bloggers.com/r-creating-a-shortcut-to-run-a-gwidgets-gui/
> Suggesting how to Creating a shortcut to run a gWidgets GUI, and
> wondered if any of you found a solution for doing this with a rook
> application.
> I suspect the solution proposed in the post might be also used for
> rook.
> Any thoughts?

Not about the post (which I did not read), but here is how I do it.
Hope it helps.

Sven

PS: I have no idea whether my approach is elegant or rubbish. If
anyone can evaluate, please let me know!


== (1) Windows batch (.bat) file (to which the shortcut points): ==

@echo off
COLOR E0
echo.
echo To finish please click 'logout' in your browser.
echo.
"C:\Programme\R\R-2.14.1\bin\i386\Rterm.exe" --no-restore --no-save <
"\\path\to\script\startup.R" > "\\path\to\logfile.txt" 2>&1
echo.
echo Done.
echo.
pause


== (2) The startup.R file: ==

#!/usr/bin/Rscript --vanilla

## I use the same script as an executable in GNU/Linux, otherwise you
## probably would not need the above line.

setwd("\\\\path\\to\\script\\")

library(RMySQL, quietly=TRUE)
library(Rook, quietly=TRUE)
source("config.R")
source("functions.R")

dbcon <- startMysql()
app <- Builder$new(Static$new(urls=c("/css", "/js"), root="."),
Brewery$new(url="/brew", root="."),
Redirect$new("/brew/index.rhtml"))
s <- Rhttpd$new()
s$add(app=app, name="mycoolapp")
s$start(quiet=TRUE)
s$browse("mycoolapp")

## After logout is clicked in the browser, SESS("r-logout") will
## return TRUE.
while(!isTRUE(SESS("r-logout"))) {
Sys.sleep(5)
}

dbDisconnect(dbcon)

cat("Bye!\n")


Tal Galili

unread,
Jun 19, 2012, 4:20:00 PM6/19/12
to rr...@googlegroups.com
Thank you for the pointers Sven,
Is there a chance you might send a simple ZIP file with an example project one could run?

Thanks!


Tal


----------------Contact Details:-------------------------------------------------------
Contact me: Tal.G...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English)
----------------------------------------------------------------------------------------------




Sven Hartenstein

unread,
Jun 20, 2012, 12:33:51 PM6/20/12
to rr...@googlegroups.com
Hi Tal and all,

> > Is there a chance you might send a simple ZIP file with an example
> > project one could run?

Yes, I attach it to this email, WITHOUT ANY WARRANTY.

You need to rename startRookApp.bat.txt to startRookApp.bat (without
the .txt extension). (This is because Google does not distribute this
email otherwise.)

In startRookApp.bat you have to adjust the path to R.
In startup.R you have to adjust the path for setwd().

Again: I have no idea whether my approach is elegant or not. It is
more of a "quick and dirty" solution rather than a bullet proof app.

Sven

simplerookapp.zip

Tal Galili

unread,
Jun 20, 2012, 4:46:19 PM6/20/12
to rr...@googlegroups.com
Hi Sven ,
Thank you very much!
I will have a look at it in the (somewhat) near future.  I am very curious to test it out and see what can be done with :)

With regards,

Tal

----------------Contact Details:-------------------------------------------------------
Contact me: Tal.G...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English)
----------------------------------------------------------------------------------------------




davidfr...@gmail.com

unread,
Jun 12, 2014, 7:30:30 AM6/12/14
to rr...@googlegroups.com
Hi Sven,

Thanks for iluminate me with this example. Now I can start up from a batch mode any R application.

Best Regards,
David
Reply all
Reply to author
Forward
0 new messages