ArulesVIZ interactive plot - Shiny R
我想为关联挖掘创建一个闪亮的网络应用程序。我想做的一件事是从包 arulesVIZ.
中实现交互式绘图
所以我有以下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | library(shiny) library(DT) library(data.table) library(arules) library(arulesViz) df_transac <-read.table("C:/Users/pauljacq/Desktop/splits/Association files/ns_transactions.csv",header=T, sep=",") t<-read.transactions("C:/Users/pauljacq/Desktop/splits/Associationfiles/ns_transactions.csv", format='single',cols=c('shipment_archive_id','ASIN'),sep=",") rules_t <- apriori(t, parameter = list(support = 0.0001, confidence = 0.0001, minlen=2, maxlen=5, ext=TRUE ), control = list(verbose=TRUE)) rules_table<-data.table(lhs=labels(lhs(rules_t)), rhs=(labels(rhs(rules_t))), quality(rules_t)) ui<- basicPage( mainPanel( tabsetPanel( tabPanel("File", DT::dataTableOutput("df_transac")), tabPanel("Rules", DT::dataTableOutput("rules")), tabPanel("Graph", plotOutput("graph")) ) ) ) server <- function(input, output) { output$df_transac = DT::renderDataTable({ df_transac }) output$rules = DT:: renderDataTable({ rules_table }) output$graph = renderPlot({ plot(rules_t,method="scatter",interactive=T) }) } shinyApp(ui=ui,server=server) |
当我拥有该应用程序时效果很好
1 | plot(rules_t,method='scatter",interactive=F) |
但是,当我有
1 | plot(rules_t,method='scatter",interactive=T) |
我有以下错误:
1 | Error in convertUnit: 'x' argument must be a unit object |
非常欢迎任何解决方案、想法或参考以前的工作:)
发生错误是因为 Shiny 似乎没有将点击位置从包
1 | plot(rules_t, method ="scatter", engine ="htmlwidget") |
代替。这将创建一个 htmlwidget 并且应该可以在闪亮的环境中正常工作。