1 / 27

Tcl/Tk package in R

Tcl/Tk package in R. Yichen Qin Department of Applied Mathematics and Statistics December 5, 2008. Today’s schedule. Introduction to Tcl/Tk package in R. Basic concepts in Tcl/Tk package Some basic example Some fancy examples (if time permitted). Introduction to Tcl/Tk package.

Download Presentation

Tcl/Tk package in R

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tcl/Tk package in R Yichen Qin Department of Applied Mathematics and Statistics December 5, 2008

  2. Today’s schedule • Introduction to Tcl/Tk package in R. • Basic concepts in Tcl/Tk package • Some basic example • Some fancy examples (if time permitted)

  3. Introduction to Tcl/Tk package

  4. What is Tcl? • Tcl, or the "Tool Command Language", is a powerfully simple, open source-licensed programming language. Tcl provides basic language features such as variables, procedures, and control structures. It runs on almost any modern OS. But the key feature of Tcl is its extensibility.

  5. What is Tk? • Tk is a Tcl extension, written in C, designed to give the user a relatively high level interface to his or her windowing environment. • GUI (Graphical user interface) extension

  6. What is Tcl/Tk? • Tcl/Tk is a combination of a scripting language and a toolkit for graphical user interfaces.

  7. What is Tcl/Tk package in R? • The Tcl/Tk package allows the use of the Tk graphical user interface elements from within R by embedding Tk commands into the R language, and replacing Tcl code with R function calls.

  8. Who developed it? • Peter Dalgaard developed this package. • He is a professor at Department of Biostatistics, University of Copenhagen • Most examples and materials in our class are from by him.

  9. Language of Tcl/Tk package • R function instead of Tcl language. • Too many commands

  10. Learning Method • The best way to learn Tcl/Tk package is through examples. • There are relatively limited material for this package, compare to other packages. • The commands are so many that no textbook will cover them all. So learning while using is the best way.

  11. Learning material • http://www.sciviews.org/_rgui/tcltk/ • http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/ • http://www.r-project.org/

  12. Basic concepts in Tcl/Tk – R with some examples

  13. A basic component: Widget • A widget is a GUI (Graphical user interface) element. • It can be: buttons, listboxes, text editing windows, sliders, text entry fields, labels, menus, and a canvas for drawing graphics.

  14. Widget example • R-prog1.R • R-prog2.R • R-prog7.R

  15. Geometry managers • A geometry manager controls the placement of widgets within a master widget. • Tkplacer() --- hardly used • Tkpack() --- places widgets in order around edges of cavity based on a order and a direction. • Tkgrid() --- lays out widgets in rows and columns

  16. Tkpacker() example • R-prog12.R

  17. Tkgrid() example • R-prog8.R

  18. Connect widgets with R • We need a way to get data from widgets to and from R, and a way to make things happen in response to widget events. • Tkconfigure() --- value-related • Tkbind() --- action-related

  19. tkconfigure() example • R-prog14.R • R-prog9.R

  20. Tkbind() example • R-prog10.R

  21. Creat a menu • Menus are created in several steps. First you setup the menu with tkmenu(), then you add items with tkadd(). There are so many possible options for a menu item that this is a more practicable approach. • Add menu backwards • Tkmenu() • Tkadd()

  22. Tkmenu() tkadd() example • R-prog4.R

  23. Some more examples

  24. examples • R-prog3.R • R-prog6.R • R-prog11.R

  25. Some advance examples with Tcl/Tk and rpanel • Rpanel is also a package that developed based on Tcl/Tk.

  26. Advanced examples • http://www.stats.gla.ac.uk/~adrian/rpanel/ • R-prog15.R • R-prog16.R • R-prog17.R • R-prog18.R • R-prog19.R • R-prog20.R

  27. Thank you • My contact information: • Email: yqin@jhu.edu • Office: Whitehead 211E

More Related