Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gwidgets gtable refresh

Tags:

r

gwidgets

I encounter the following problem:

library(gWidgets)
options(guiToolkit = "RGtk2")

aa <- c(1,2,3)
bb <- c(4,5,6)
cc <- cbind(aa,bb)
cc <-as.data.frame(cc)

t1 <- gtable(cc, container=TRUE)

I want to refresh the content of t1 with:

dd <- c(7,8,9)
dd <- as.data.frame(dd)

But when I run

t1[] <- dd

I receive: Can't replace with fewer columns

Apostolos

like image 959
Apostolos Avatar asked Jul 03 '11 19:07

Apostolos


2 Answers

To expand upon John's answer, here's an example.

#Data
cc <- data.frame(aa = 1:3, bb = 4:6)
dd <- data.frame(X = 7:9)

#Wigdets
win <- gwindow()
grp <- ggroup(container = win)
t1 <- gtable(cc, container = grp)

#Refresh widget
delete(grp, t1)
t1 <- gtable(dd, container = grp)

Note that the sample code in the question works fine under gWidgetstcltk; it's a purely GTK issue.

like image 193
Richie Cotton Avatar answered Oct 31 '22 08:10

Richie Cotton


The gtk widget makes you pick the type of column at construction, so gtable doesn't let you have fewer columns or change column types. If you really want to do this, put the widget in a ggroup container, then delete and add a new widget.

like image 34
jverzani Avatar answered Oct 31 '22 09:10

jverzani