[R] How to create an executable file from R GUI?

Adrian Dușa dusa.adrian at unibuc.ro
Sun Feb 21 10:37:24 CET 2016


Oh, thanks Peter, good example for Mac, but indeed not working on Windows.
For a completely cross-platform solution (that is, including Windows which
is what Zahra wants), I believe shiny is the right tool.

So Zahra, if you want to use shiny, you need to look at their own
tutorials, step by step, and try to understand how it works.
They have predefined tools to make "apps", which can be deployed either
locally or on a web server. But you will be dependent on the available
shiny toolkit.
Otherwise, if you want to make a completely customized interface, you need
to use a combination of R, HTML and Javascript.

Take a look at the GUI from the QCAGUI package (download the sources, it's
in the "inst" directory): it can read the local filesystem, import / export
data, it does various data transformations and various QCA related analyses
and graphs.
Everything is highly customized, with drop-down menus and pop-up dialogs,
including an output one which mimics the R console.
To look at the interface, type:

library(QCAGUI)
runGUI()

I hope it helps,
Adrian

On Sat, Feb 20, 2016 at 2:46 PM, peter dalgaard <pdalgd at gmail.com> wrote:

> It's quite platform dependent, but this idea works for tcl/tk on Mac. I
> don't think it would be too hard to do similar things on Linux, Windows may
> be a bigger challenge (or not).
>
> Peter-Dalgaards-MacBook-Air:tmp pd$ cat foo.app
> #!/usr/bin/Rscript
> library(tcltk)
> demo(tkfaq)
> tkwait.variable("exit")
>
> Make it executable (chmod +x foo.app) and you can double-click it in the
> Finder. (Notice that as written, there is nothing to shut down the tkwait
> loop, so you'll have to force quit it.)
>
> Peter D.
>
> > On 19 Feb 2016, at 23:36 , Adrian Dușa <dusa.adrian at unibuc.ro> wrote:
> >
> > Your function, buildGui(), what does it use, Tcl/Tk or something else?
> > If it's Tcl/Tk, I believe you need a normal R console opened. My .bat
> file
> > only works for a command line, which is fine if the user interface opens
> up
> > in a webpage, but I'm pretty sure it doesn\t work with Tcl/Tk.
> > What kind of window does your function return?
> > Adrian
> >
> > On Fri, Feb 19, 2016 at 4:35 PM, Zahra Samadi <simon0098 at yahoo.com>
> wrote:
> >
> >> Adriana,
> >> My GUI file is a function returning a window. This function is named
> >> buildGui(). How should I create this batch file using the piece of code
> >> you've written?
> >>
> >> ------------------------------
> >> * From: * Adrian Dușa <dusa.adrian at unibuc.ro>;
> >> * To: * Greg Snow <538280 at gmail.com>;
> >> * Cc: * simon0098 at yahoo.com <simon0098 at yahoo.com>; r-help at r-project.org
> <
> >> r-help at r-project.org>;
> >> * Subject: * Re: [R] How to create an executable file from R GUI?
> >> * Sent: * Thu, Feb 18, 2016 9:03:52 PM
> >>
> >> Simon, Greg,
> >>
> >> That is the very reason why I've given up on Tck/Tk, in favor of shiny.
> >> The user interface opens up in a webpage, without opening the normal R
> >> console (it only opens a Terminal window).
> >>
> >> To exemplify, package QCAGUI has a function called runGUI(), and on
> >> Windows it's a simple matter of creating a .bat file,
> >> which for my user interface it only contains this:
> >>
> >> CLS
> >>
> >> TITLE QCA Qualitative Comparative Analysis
> >>
> >> C:/PROGRA~1/R/R-3.2.3/bin/R.exe --slave --no-restore -e
> >> "setwd('D:/');QCAGUI::runGUI()"
> >>
> >>
> >> The double click on the .bat file, and that's it.
> >> I hope it helps,
> >> Adrian
> >>
> >>
> >>
> >> On Thu, Feb 18, 2016 at 7:24 PM, Greg Snow <538280 at gmail.com> wrote:
> >>
> >>> To give a full answer we need some more detail from you.  For example
> >>> what operating system are you on? what do you mean by "users click on
> >>> it"? and at what point do you want them to click (after running R,
> >>> when looking at the desktop, etc.)
> >>>
> >>> But to help get you started you may want to look at the help page
> >>> `?Startup` which tells you all the things that R does as it starts up
> >>> and how to have it run commands automatically as it is starting up.
> >>>
> >>> I have created some GUI examples in the past that clients then wanted
> >>> to have on their own computer to play with and demonstrate to others.
> >>> I usually would install R on their machine for them and create a
> >>> shortcut on the desktop (these were all MS Windows computers) that
> >>> pointed to the standard R executable, but started in a specific
> >>> directory/folder.  Then in that folder I created a ".Rprofile" file
> >>> with the commands to load in the appropriate data and packages and run
> >>> the gui demonstration.  The user could then double click on the
> >>> shortcut on the desktop and 2 windows would pop up (the regular R
> >>> interface and my gui demo), I instructed the client to just minimize
> >>> and ignore the regular R window and they were then able to use my demo
> >>> and then close everything when they were finished.  You could do
> >>> something similar (but exactly how will differ between Windows, Mac,
> >>> and Linux computers).
> >>>
> >>> On Thu, Feb 18, 2016 at 9:27 AM, simon0098--- via R-help
> >>> <r-help at r-project.org> wrote:
> >>>> Hi,
> >>>> I've created a GUI using RGtk2 package. How can I make an executable
> >>> file from my R script so that users click on it and the GUI appears for
> >>> them?
> >>>>
> >>>>
> >>>>        [[alternative HTML version deleted]]
> >>>>
> >>>> ______________________________________________
> >>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >>>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>>> PLEASE do read the posting guide
> >>> http://www.R-project.org/posting-guide.html
> >>>> and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>>
> >>>
> >>> --
> >>> Gregory (Greg) L. Snow Ph.D.
> >>> 538280 at gmail.com
> >>>
> >>>
> >>> ______________________________________________
> >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide
> >>> http://www.R-project.org/posting-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>>
> >>
> >>
> >> --
> >> Adrian Dusa
> >> University of Bucharest
> >> Romanian Social Data Archive
> >> Soseaua Panduri nr.90
> >> 050663 Bucharest sector 5
> >> Romania
> >>
> >
> >
> >
> > --
> > Adrian Dusa
> > University of Bucharest
> > Romanian Social Data Archive
> > Soseaua Panduri nr.90
> > 050663 Bucharest sector 5
> > Romania
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Adrian Dusa
University of Bucharest
Romanian Social Data Archive
Soseaua Panduri nr.90
050663 Bucharest sector 5
Romania

	[[alternative HTML version deleted]]



More information about the R-help mailing list