Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel:...
Transcript of Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel:...
![Page 1: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/1.jpg)
Statistical Cartoons
rpanel: simple interactive controls for R functionsusing the tcltk package
Ewan Crawford, Adrian Bowman
Department of Statistics, The University of Glasgow, UK
![Page 2: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/2.jpg)
Elementary example
![Page 3: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/3.jpg)
Code for example
library(rpanel)
x11(width=4,height=4)
qq.draw <- function(panel) {
z <- bc.fn(panel$y, panel$lambda)
qqnorm(z, main = paste("lambda =",
round(panel$lambda, 2)))
panel
}
panel <- rp.control(y = exp(rnorm(50)), lambda = 1)
rp.slider(panel, lambda, -2, 2, qq.draw,
showvalue = TRUE)
![Page 4: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/4.jpg)
Second elementary example
![Page 5: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/5.jpg)
Second elementary example
![Page 6: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/6.jpg)
Relationship with wider gui packages
Relationship with wider ("widgety") gui packages
- Rgtk2
- gWidgets
- playwith
- rwxwidgets
- JGR
- rtcltk
...
![Page 7: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/7.jpg)
Indication of tools available
What we offer in terms of widgets
- panel/window
- button (with repeat)
- slider/scrollbar
- radiogroup
- textentry (or multiples)
- checkbox (or multiples)
- listbox
- doublebutton
- image
- line
- messagebox
- tkrplot
...
![Page 8: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/8.jpg)
Gulls
![Page 9: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/9.jpg)
Spatial examples: Geosim
![Page 10: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/10.jpg)
Spatial examples: Mururoa
![Page 11: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/11.jpg)
Spatial examples: Rosyth
![Page 12: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/12.jpg)
Current developments
Current developments
- multi-line text box
- combo box
- pos/grid
- tabbed notebook
- fonts
- slider group
...
- essentially all BWidgets and TkTable
- More Cartoons
![Page 14: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/14.jpg)
-
![Page 15: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/15.jpg)
What
- what i’ll talk about, widgets and their uses
- cartoons explanation
![Page 16: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/16.jpg)
Why
- applications
- rationale (teach dept etc etc)
- xlispstat etc
![Page 17: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/17.jpg)
soa2
Big heading: RGtk2
Sub heading: GTK+
Project page:
http://www.gtk.org
An example of what can be done with GTK+, The GIMP
Illustrated by image
![Page 18: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/18.jpg)
![Page 19: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/19.jpg)
soa2
Sub heading: RGtk2
Project page:
http://www.ggobi.org/rgtk2/
Example of what can be done with Rgtk2, demo
Illustrated by image
![Page 20: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/20.jpg)
![Page 21: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/21.jpg)
soa2
** Third slide: (May not all fit on the one slide, see my note to you
about omitting the code below)
Big heading: Gwidgets
Project page:
http://wiener.math.csi.cuny.edu/pmg/gWidgets
Illustrated by images
![Page 22: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/22.jpg)
![Page 23: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/23.jpg)
Gwidgets code example (for the slider image)
Adrian - if you see fit, do not include this code. It may be worth
including out of fairness as gwidgets is the only easy alternative to
using rpanel
library(gWidgets)
![Page 24: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/24.jpg)
options("guiToolkit"="RGtk2")
require(lattice)
dataSet = faithful$eruptions
w = gwindow("Slider example")
g = gpanedgroup(cont=w)
g1 = ggroup(horizontal = FALSE, cont = g) # first is left
gg = ggraphics(cont = g) # second is right
sl <- gslider(1, length(dataSet), by = 1, cont=g1, handler =
function(h,...) { print(histogram(dataSet, nint = svalue(h$obj)))
svalue(sb) <- svalue(h$obj)
})
sb <- gspinbutton(1, length(dataSet), by = 1, cont=g1, handler =
function(h,...) {
print(histogram(dataSet, nint = svalue(h$obj)))
![Page 25: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/25.jpg)
svalue(sl) <- svalue(h$obj)
})
l = glabel("adjust number of bins", cont=g1)
histogram(dataSet) # start it off
![Page 26: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/26.jpg)
soa2
** Slide Four
Big heading: rwxwidgets
Project page:
http://www.omegahat.org/RwxWidgets/
Illustrate rwxwidgets image:
![Page 27: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/27.jpg)
** Slide Five
Big heading: JGR
Project page:
http://rosuda.org/JGR/
Illustrations:
![Page 28: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/28.jpg)
![Page 29: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/29.jpg)
![Page 30: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/30.jpg)
** Slide Five
** Slide Six
rtcltk
Pages:
http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/
Illustative image: rtcltk_editbox2.jpg
![Page 31: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/31.jpg)
soa
- ---as per lanc --- - get images -
+ new -> Playwith
![Page 32: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/32.jpg)
method
- who did what
- adrian b, simon urbanek, gavin, richard b
- tcl/tk and internals
- list of controls/widgets/facilities (but not exhaustive?)
![Page 33: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/33.jpg)
examples
- preview of examples - click to run - check what runs -
![Page 34: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/34.jpg)
examples
- preview of examples - click to run - check what runs -
![Page 35: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/35.jpg)
examples
- tables(panel)
![Page 36: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/36.jpg)
examples
- normal fitting
![Page 37: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/37.jpg)
examples
- preview of examples - click to run - check what runs -
![Page 38: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/38.jpg)
examples
- regression 1d
![Page 39: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/39.jpg)
examples
- cosine regression
![Page 40: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/40.jpg)
examples
- density est 1d
![Page 41: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/41.jpg)
examples
- gulls
![Page 42: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/42.jpg)
examples
- clyde map
![Page 43: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/43.jpg)
examples
- spatial sim
![Page 44: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/44.jpg)
examples
- mururoa
![Page 45: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/45.jpg)
examples
- rosyth
![Page 46: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/46.jpg)
code
*** As per Adrian’s build up? ***
panel <- rp.control("Clyde data", do = DO, days = Days)
panel <- rp.slider(panel, day.adj, 0, 364,
action = days.plot)
panel <- rp.checkbox(panel, model.showing, model.fn,
title = "Show model")
Behind the scenes . . .
panel <- action(panel)
![Page 47: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/47.jpg)
reaction
- discuss with AB
- applications
![Page 48: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/48.jpg)
discussion
- my comments, pros, cons
- future plans
- pos, grid, notebook, combo ...
![Page 49: Ewan Crawford, Adrian Bowman - R: The R Project for ...Bowman.pdf · Statistical Cartoons rpanel: simple interactive controls for R functions using the tcltk package Ewan Crawford,](https://reader031.fdocuments.net/reader031/viewer/2022040814/5e5b0e6e10a5f209877b030f/html5/thumbnails/49.jpg)
Web site
www.stats.gla.ac.uk/~adrian/rpanel