r - 闪亮的 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)
解决方案
方法“graph”从 visNetwork 返回一个 htmlwidget,所以你需要使用renderVisNetwork()
而不是renderPlotly()
在 shiny。
推荐阅读
- javascript - 与 Ruby 相比,在 Javascript 中,在遍历数组时,您是否不需要“保护”以防止迭代器越界?
- javascript - 将 Cookie 添加到 API
- java - 递归遍历java中的矩阵以找到最佳路径
- for-loop - 基于生成行以在数据框的列中创建序列
- c - 如何在 C 中实现多个定时器?
- python-turtle - 乌龟 onscreenclick 在 Python 中返回什么?如何使区域成为“按钮”?
- python - 从 Pandas 系列中的字典列表创建 DataFrame
- javascript - 如何使用 setTimeout/setInterval 显示显示不同时间的图像
- java - 如何实现 Java 8 LocalTimeDeserializer?
- javascript - HTTPOnly cookie 在 Next JS 的 getServerSideProps 中不可用