[R] Tcl Tk table
thsudler@swissonline.ch
thsudler at swissonline.ch
Fri Apr 23 15:47:46 CEST 2004
Hi
I've a problem with the following example:
library(tcltk)
.Tcl("array unset tclArray")
myRarray <- matrix(1:1000, ncol=20)
for (i in (0:49))
for (j in (0:19))
.Tcl(paste("set tclArray(",i,",",j,") ",myRarray[i+1,j+1],sep=""))
tt<-tktoplevel()
table1 <- tkwidget(tt,"table",variable="tclArray", rows="50", cols="50")
tkpack(table1)
#Old version which worked in R 1.6 but it doesn't work with R 1.9 (and also not with 1.8), why??
tkcmd(.Tk.ID(table1),"tag","celltag","gruen",list(c("3,3", "4,4", "5,5", "6,6", "7,7", "8,8")))
tkcmd(.Tk.ID(table1),"tag","configure","gruen",bg="green",fg="green")
#Error message: Error in switch(storage.mode(x), character = .External("RTcl_ObjFromCharVector", : Cannot handle object of mode list
#But this works also with R 1.9
tkcmd(.Tk.ID(table1),"tag","celltag","gruen","3,3","4,4","5,5","6,6","7,7","8,8")
tkcmd(.Tk.ID(table1),"tag","configure","gruen",bg="green",fg="green")
Under R version 1.6 I had no problem. Now I installed R 1.9 (with ActiveTcl) and my program doesn't work. Maybe you ask why Im not using the solution which works. It's because I've a list with thousands of coordiantes of cells which I want to have green, a list with thousands of coordinates of cells which I want to have blue, and so on.
If I do this in a "for loop", it needs about 5 minutes until all the cells have the color I want (because it's a really big table). Also with "lapply" it needs about 3 minutes. In R version 1.6 (where it worked with a "list") the table was generated in less than 1 second!
I would be very grateful if somebody could help me. Thanks a lot in advance!
Thomas
More information about the R-help
mailing list