gwidgets gtable 刷新

发布于 2024-11-18 13:08:31 字数 441 浏览 1 评论 0原文

我遇到以下问题:

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)

我想刷新 t1 的内容:

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

但是当我运行时

t1[] <- dd

,我收到: Can't replacement with less columns

Apostolos

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

久伴你 2024-11-25 13:08:31

为了扩展约翰的答案,这里有一个例子。

#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)

请注意,问题中的示例代码在 gWidgetstcltk 下工作正常;这纯粹是GTK问题。

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.

空袭的梦i 2024-11-25 13:08:31

gtk 小部件使您可以在构造时选择列的类型,因此 gtable 不允许您减少列或更改列类型。如果您确实想这样做,请将小部件放入 ggroup 容器中,然后删除并添加新的小部件。

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.

三五鸿雁 2024-11-25 13:08:31

如果只是刷新而不是完全更改其内容,我会通过以下方式获得非常好的体验:

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 

完整的“刷新”可能如下所示:

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

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文