[R] tclArray() --- "active"?!

peter dalgaard pdalgd at gmail.com
Wed Jul 6 17:35:34 CEST 2016


I am not up to speed on Tcl/Tk these days, but I would suspect that the issue lies in tkTable and not in tclArray. The table widget has the notion of an active cell, which can be used in indexing operations. According to the widget documentation

--
Command-Line Name:-variable
Database Name: variable
Database Class: Variable

Global Tcl array variable to attach to the table's C array. It will be created if it doesn't already exist or is a simple variable. Keys used by the table in the array are of the form row,col for cells and the special key active which contains the value of the active cell buffer. [...]
--

I think this suggests that you just need to assume that the "active" element might be there when you deal with the tclArray and work around it if it gets in the way. 

(A conjecture as to why it appears in your example could be that you deleted the row with the active cell, and that the widget needs to record the fact that there is now no active cell.)

-pd
 

> On 06 Jul 2016, at 16:18 , Dalthorp, Daniel <ddalthorp at usgs.gov> wrote:
> 
> Sometimes when working with tclArray's, an empty element called "active" is
> appended to the array. Does anyone know when (and why) this happens? And
> how to prevent it (or at least predict it so that it can be removed by
> hand)?
> 
> E.g.,
> library(tcltk); library(tcltk2)
> tt<-tktoplevel()
> dat<-tclArray()
> tab<-tk2table(tt, variable = dat)
> tkgrid(tab)
> dat[[0,0]]<-5
> dat[[1,0]]<-4
> dat[[2,0]]<-56
> tkdelete(tab,"rows",2, 8)
> names(dat)
> 
> Any help would be greatly appreciated!
> 
> -Dan
> 
> -- 
> Dan Dalthorp, PhD
> USGS Forest and Rangeland Ecosystem Science Center
> Forest Sciences Lab, Rm 189
> 3200 SW Jefferson Way
> Corvallis, OR 97331
> ph: 541-750-0953
> ddalthorp at usgs.gov
> 
> 	[[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



More information about the R-help mailing list