无法 运行 使用 grVizOutput() 和 renderGrViz() 的 Shiny App
Unable to run a Shiny App using grVizOutput() and renderGrViz()
到目前为止,我真的很喜欢在 DiagrammeR
中使用和创建图表。我能够在 RStudio 中创建它们。最近我正在准备一个闪亮的应用程序以使用 DiagrammeR
(grViz
函数)包含一个图表,我查看了 github 并找到了如何执行相同操作的示例(请参阅 here).
但是我一直在尝试但无法在闪亮的应用程序中获得输出。
请找到我正在尝试的以下代码 (app.R
) :
library(DiagrammeR)
library(shiny)
diagram <- "
digraph {
# graph attributes
graph [overlap = true]
# node attributes
node [shape = box,
fontname = Helvetica,
color = blue]
# edge attributes
edge [color = gray]
# node statements
A; B; C; D; E
F [color = black]
# node attributes
node [shape = circle,
fixedsize = true,
width = 0.9]
# node statements
1; 2; 3; 4; 5; 6; 7; 8
# edge statements
A->1; B->2 // gray
B->3 [color = red] // red
B->4 // gray
C->A [color = green] // green
1->D; E->A; 2->4; 1->5; 1->F // gray
E->6; 4->6; 5->7; 6->7 // gray
3->8 [color = blue] // blue
}
"
# Shiny app
server <- function(input, output) {
output$diagram <- renderGrViz({
grViz({
diagram
})
})
}
ui <- fluidPage(
grVizOutput('diagram', width = "100%", height = "760px")
)
shinyApp(ui = ui, server = server)
我在 Rstudio 1.2.1335 版本 Windows 10 上使用 R 版本 3.6.0,闪亮版本 1.4.0,DiagrammeR 版本 1.0.5。在执行上面的代码时,我总是得到以下错误并且 Shiny 应用程序没有打开。
> runApp()
Listening on http://127.0.0.1:4391
Warning: Error in htmlwidgets::shinyRenderWidget: unused argument (evn = env)
50: renderGrViz
49: server [C:\Users\HomeUser\Documents\RWorkSpace\SampleApp/app.R#46]
Error in htmlwidgets::shinyRenderWidget(expr = expr, outputFunction = grVizOutput, :
unused argument (evn = env)
任何人都可以指导上面的代码有什么问题吗?
我得到了和你一样的错误信息,但是当我将 DiagrammeR 包降级到 1.0.1 时一切正常。
library(devtools)
install_version("DiagrammeR", version = "1.0.1", repos = "http://cran.us.r-project.org")
到目前为止,我真的很喜欢在 DiagrammeR
中使用和创建图表。我能够在 RStudio 中创建它们。最近我正在准备一个闪亮的应用程序以使用 DiagrammeR
(grViz
函数)包含一个图表,我查看了 github 并找到了如何执行相同操作的示例(请参阅 here).
但是我一直在尝试但无法在闪亮的应用程序中获得输出。
请找到我正在尝试的以下代码 (app.R
) :
library(DiagrammeR)
library(shiny)
diagram <- "
digraph {
# graph attributes
graph [overlap = true]
# node attributes
node [shape = box,
fontname = Helvetica,
color = blue]
# edge attributes
edge [color = gray]
# node statements
A; B; C; D; E
F [color = black]
# node attributes
node [shape = circle,
fixedsize = true,
width = 0.9]
# node statements
1; 2; 3; 4; 5; 6; 7; 8
# edge statements
A->1; B->2 // gray
B->3 [color = red] // red
B->4 // gray
C->A [color = green] // green
1->D; E->A; 2->4; 1->5; 1->F // gray
E->6; 4->6; 5->7; 6->7 // gray
3->8 [color = blue] // blue
}
"
# Shiny app
server <- function(input, output) {
output$diagram <- renderGrViz({
grViz({
diagram
})
})
}
ui <- fluidPage(
grVizOutput('diagram', width = "100%", height = "760px")
)
shinyApp(ui = ui, server = server)
我在 Rstudio 1.2.1335 版本 Windows 10 上使用 R 版本 3.6.0,闪亮版本 1.4.0,DiagrammeR 版本 1.0.5。在执行上面的代码时,我总是得到以下错误并且 Shiny 应用程序没有打开。
> runApp()
Listening on http://127.0.0.1:4391
Warning: Error in htmlwidgets::shinyRenderWidget: unused argument (evn = env)
50: renderGrViz
49: server [C:\Users\HomeUser\Documents\RWorkSpace\SampleApp/app.R#46]
Error in htmlwidgets::shinyRenderWidget(expr = expr, outputFunction = grVizOutput, :
unused argument (evn = env)
任何人都可以指导上面的代码有什么问题吗?
我得到了和你一样的错误信息,但是当我将 DiagrammeR 包降级到 1.0.1 时一切正常。
library(devtools)
install_version("DiagrammeR", version = "1.0.1", repos = "http://cran.us.r-project.org")