【发布时间】:2021-11-21 13:59:07
【问题描述】:
为了能够调整使用DiagrammeR 包生成的图形输出的大小(已在此处解释:https://github.com/rich-iannone/DiagrammeR/issues/93),我需要将grVizOutput 封装在服务器中的renderUI 中并通过以下方式调用它
uiOutput 在用户界面中。
这段代码不断返回以下错误:
Error in as.vector: cannot coerce type 'closure' to vector of type 'character'
注意:直接在 UI 中调用 grVizOutput 可以,但不要让我动态调整图表大小。
知道为什么这没有按预期工作吗?
library(shiny)
library(DiagrammeR)
library(magrittr)
##------------------------------------------
## ui function
ui <- shinyUI(fluidPage(
fluidRow(
column(
width = 8,
uiOutput('d')
)
)
)
)
##------------------------------------------
## server function
server <- function(input, output){
output$d <- renderUI({
grVizOutput(
renderGrViz({grViz("digraph boxes_and_circles {
# a 'graph' statement
graph [overlap = true, fontsize = 10]
# several 'node' statements
node [shape = box,
fontname = Helvetica]
A; B; C; D; E; F
node [shape = circle,
fixedsize = true,
width = 0.9] // sets as circles
1; 2; 3; 4; 5; 6; 7; 8
# several 'edge' statements
A->1 B->2 B->3 B->4 C->A
1->D E->A 2->4 1->5 1->F
E->6 4->6 5->7 6->7 3->8
}")})
)
})
}
##------------------------------------------
## run app
shinyApp(ui = ui, server = server)
【问题讨论】:
标签: r shiny diagrammer