Version 33 of R

Updated 2012-01-05 10:40:29 by dkf

See also the alphabet.


Interfacing R and Tcl

 What: R
 Where: http://www.r-project.org/ 
        http://cran.r-project.org/ 
        http://lib.stat.cmu.edu/R/ 
        http://www.gnu.org/software/r/R.html >
        http://www.ci.tuwien.ac.at/%7Ehornik/R/R-FAQ.html 
        http://stat.auckland.ac.nz/rproj.html 
        http://phaseit.net/claird/comp.os.linux.development.system/ServerClinic.html 
 Description: Statistical computing and visualization language,
        similar to the S language.
        R is "a language and environment for statistical computing
        and graphics" (http://www.r-project.org/about.html  ) For more
        background on R, see the February 2003 installment of "Server Clinic".
        Provides a wide variety of techniques.
        Comes with a tcltk package, providing interface and language bindings
         for Tcl/Tk.
        Makes use of plplot.
        Note that Mark Myatt mailto:[email protected]  is
         writing a syntax highlighting editor to be used as a front-end
         of R; contact him for details.
        Currently at version 2.6.0 .
 Updated: 11/2007
 Contact: See web site

See also the article series here [L1 ] and here [L2 ].

R has bindings to Tcl, Tk, and Visual Tcl through the R packages 'tcltk' and 'vtcl'. The 'tcltk' package creates and uses tcl/tk interpreters from R. This tcl interpreter inside R has an additional command 'R some R commands' which can execute R commands, e.g, 'R a<-rnorm(100)'. The 'vtcl' package contains only one function 'visual.tcl()' which enables the user to run Visual Tcl from inside R. (See the original announcement here: [L3 ])

Seductive screen-shots appear at http://www.bioconductor.org/Screenshots/index.html , for example. Brodgar is crucial.

Peter Dalgaard says in comp.lang.tcl that http://CRAN.R-project.org/doc/Rnews/ should be used as a source for more recent information; particularly in vol 1/3 and 2/3.

He goes on to say:

"What we currently have is a Tcl interpreter embedded in R and interface routines and (some) object reflection and communication mechanisms, which allow you to run Tcl stuff from within R.
What we don't have is the reverse: Mechanisms that let you control R from Tcl. Well, we do have some rudiments of it, but not as elaborate as in the other direction. In principle R is embeddable; you can build R as a shared object and link it into another program, but you probably need to jump through a few hoops to get event loops and such stuff right. (I believe http://developer.r-project.org/embedded.html is the best documentation we have.)"

That was the situation in early 2003. A few hours before the year ended, though, Neil McKay announced availability of Rtcl.


References, etc.

AM (14 november 2005) I saw this article this morning:

Title:
The R commander: A basic-statistics graphical user interface to R

Authors:
Fox, J

Source:
JOURNAL OF STATISTICAL SOFTWARE, 14 (9): - SEP 2005

Abstract:
Unlike S-PLUS, R does not incorporate a statistical graphical user interface (GUI), but it does include tools for building GUIs. Based on the tcltk package (which furnishes an interface to the Tcl/Tk GUI toolkit), the Rcmdr package provides a basic-statistics graphical user interface to R called the "R Commander." The design objectives of the R Commander were as follows: to support, through an easy-to-use, extensible, cross-platform GUI, the statistical functionality required for a basic-statistics course (though its current functionality has grown to include support for linear and generalized-linear models, and other more advanced features); to make it relatively difficult to do unreasonable things; and to render visible the relationship between choices made in the GUI and the R commands that they generate. The R Commander uses a simple and familiar menu/dialog-box interface. Top-level menus include File, Edit, Data, Statistics, Graphs, Models, Distributions, Tools, and Help, with the complete menu tree giv

Link: http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/


GS (061016) Slides about a talk: The R-Tcl/Tk interface: Potential usage for graphical models, Peter Dalgaard. [L4 ]

And an article by the same author: The R-Tcl/Tk interface, Peter Dalgaard. [L5 ]


At the implementation level, R is a very interesting language with an approach which is very close to Tcl, yet implemented in a totally different way. In an expression such as "a = myfunc(1,b+2)" the arguments are passed in unevaluated form, sort of as a parse tree AFAIK. Inside myfunc, each argument is named, but the association is such that the first access to each argument will actually evaluate it (in the caller's context, of course). So in day-to-day use, the behavior of a function call in R is relatively normal.

The point is that it is possible to get at the incoming unevaluated form and that an argument can be force-evaluated more than once, with side effects and all. Therefore - like Tcl - R can use normal functions to implement control structures: "if(a<b,c=1,c=2)", since only the selected argument will be evaluated. Likewise for "while" and so on.

Like Tcl, R uses copy-on-write (COW) semantics, reference counts, and data sharing.

There is a book which describes S (the non-OSS precursor of R) called "Programming with Data", by John. M. Chambers. It lists S's delightfully concise goal: To turn ideas into software, quickly and faithfully.

-jcw


[L6 ] PBS Modelling provides software to facilitate the design, testing, and operation of computer models. It focuses particularly on tools that make it easy to construct and edit a customized graphical user interface (GUI). Although it depends heavily on the R interface to the Tcl/Tk package, a user does not need to know Tcl/Tk.


See also