[R] Lists, Vectors, TclTk

Duncan Murdoch murdoch at stats.uwo.ca
Mon May 9 09:36:43 CEST 2005

Timothy Downs wrote:
> I am trying to create an array of tkwidgets in R, as in the following example:
> require(tcltk)
> tt <- tktoplevel()
> cbs <- c()
> for(i in 1:40) cbs[i] <- tkcheckbutton(tt)
> This only stores the $ID part returned by tkcheckbutton. How would I go about doing correctly?

Use cbs[[i]] <- tkcheckbutton(tt).

I'd also recommend using cbs <- list() instead of cbs <- c() because I 
find it represents your intentions more clearly, but both work.

Duncan Murdoch

More information about the R-help mailing list