R:GMISC /网格和盒子的对齐
我想使用“ GMISC”,“网格”创建一个动态流程,并在R中列出。
基本上,代码看起来如下:
##############################
library(Gmisc)
library(grid)
# list of names
a.names <- list("i1", "i2", "i3")
# list of boxes
a <- list(boxGrob("item 1"),
boxGrob("item 2"),
boxGrob("item 3")
)
# asigning names to list
names(a) <- a.names
# spreading boxes
b <- spreadHorizontal(a)
names(b) <- (a.names)
# clear view
grid.newpage()
# print boxes spread horizontal
b
现在,第二个框列表应沿第一个框垂直对齐(项目1)(项目1) 。
使用
alignHorizontal(reference = b$i1, a) %>% spreadVertical(.from = 0.9, .to=0.6)
错误的结果,虽然
dummy <- b$i2
temp <- alignHorizontal(reference = dummy, a$i1, a$i2)
spreadVertical(temp, .from=0.9, .to=0.6)
工作正常,并
dummy <- b$i3
temp <- alignHorizontal(reference = dummy, a)
spreadVertical(temp, .from=0.9, .to=0.6)
导致错误。 显然,alignhorizontal
需要单个元素,并且无法处理元素列表。 是否有机会将框列表交给该功能?
真挚地, 史蒂芬
I would like to create a dynamic flow-chart using "Gmisc", "grid", and lists in R.
Basically the code looks as follows:
##############################
library(Gmisc)
library(grid)
# list of names
a.names <- list("i1", "i2", "i3")
# list of boxes
a <- list(boxGrob("item 1"),
boxGrob("item 2"),
boxGrob("item 3")
)
# asigning names to list
names(a) <- a.names
# spreading boxes
b <- spreadHorizontal(a)
names(b) <- (a.names)
# clear view
grid.newpage()
# print boxes spread horizontal
b
Now, a second list of boxes should be aligned vertically along the first box (Item 1).
using
alignHorizontal(reference = b$i1, a) %>% spreadVertical(.from = 0.9, .to=0.6)
results in an error, while
dummy <- b$i2
temp <- alignHorizontal(reference = dummy, a$i1, a$i2)
spreadVertical(temp, .from=0.9, .to=0.6)
works fine, and
dummy <- b$i3
temp <- alignHorizontal(reference = dummy, a)
spreadVertical(temp, .from=0.9, .to=0.6)
results in an error.
Obviously, the alignHorizontal
needs single elements and cannot deal with a list of elements.
Is there any chance to hand over a list of boxes to that function?
Sincerely,
Steffen
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过列表的一个选项是使用
do.call
喜欢:One option to pass your list would be to use
do.call
like so: