首页 > 解决方案 > 闪亮的 arules htmlwidget 图形仅填充在查看器中

问题描述

我正在尝试创建一个用于可视化关联规则的闪亮应用程序。它运行良好,除了图表不断在 R Studio Viewer 中而不是在 Shiny 应用程序中填充。请帮忙!。下面的代码(正在运行 R v 3.4.2)

ui<-fluidPage(
titlePanel("test"),
sidebarLayout(
sidebarPanel(
radioButtons("hier", "Hierarchy:", c("DEPT", "SUB_DEPT", "CLASS")),      
selectInput("period",label = em("Period"), c("P1","P2"),selected = 'P1'),      
sliderInput("n_rules", "No. of rules:",min = 0, max = 100, value = 10, 
step = 10)
),
mainPanel(plotlyOutput("network_graph"))
)
)
server <- function(input, output){
output$network_graph <- renderPlotly({    
if (input$hier == 'DEPT' & input$period == 'P1') {
print(
(
plot(head(sort(DEPT_P1_All_Customers),input$n_rules), engine = 
"htmlwidget", method = "graph", height = "800px")
))
}
})
}
shinyApp(ui, server)

标签: rshinyplotlyarules

解决方案


方法“graph”从 visNetwork 返回一个 htmlwidget,所以你需要使用renderVisNetwork()而不是renderPlotly()在 shiny。


推荐阅读