gwidgets gtable refresh

非 Y 不嫁゛ 提交于 2019-12-13 12:04:21

问题


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


回答1:


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.




回答2:


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.




回答3:


If it is only about refreshing instead of completely changing its content I made very nice experience with something like this:

win <- gtable(data.frame(a=rnorm(100),b=runif(100)),container=T)
win[1,1] <- 5
win[1:10,2] <- 6
win[seq(dim(win)[1]),seq(dim(win)[2])] <- win[seq(dim(win)[1]),seq(dim(win)[2])] +1 

a complete 'refresh' might look like this:

win <- gtable(data.frame(a=rnorm(100),b=runif(100),d=FALSE),container=T)


来源:https://stackoverflow.com/questions/6564995/gwidgets-gtable-refresh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!