在闪亮的R中绘制交互式arulesViz图

时间:2015-10-01 07:04:58

标签: r shiny interactive arules

我需要在闪亮的情况下显示交互式关联规则图。为此,我使用arulesViz包。但是,当我尝试使用以下内容显示交互式散点图时:

shinyServer(function(input, output) {
output$plot1<-renderPlot({
rules <- apriori(transaction_all[[as.numeric(input$level)]],parameter=list(support=input$support,confidence=input$confidence))
plot(rules, measure=c("support", "lift"), shading="confidence",interactive = TRUE)
})

它抛出一个错误:

Error in convertUnit(x, unitTo, "x", "location", "x", "location", valueOnly = valueOnly) : 
 'x' argument must be a unit object

怎么可以这样做? 感谢

ui.R看起来像这样

shinyUI(pageWithSidebar(

#  Application title
headerPanel("Sliders"),

# Sidebar with sliders that demonstrate various available options
sidebarPanel(
# Simple integer interval
      selectInput("level", label = h3("select level to mine"), 
            choices = list("Level-1" = 1, "Level-2" = 2, "Level-3" = 3,"Level-4" = 4), 
            selected = 1),
sliderInput("support", "Support:", 
            min=0, max=1, value=0.5),
sliderInput("confidence", "Confidence:", 
            min=0, max=1, value=0.5),
width=3 
),

 mainPanel(
plotOutput("plot1")
 )
))

Server.R看起来像这样

library(shiny)

shinyServer(function(input, output) {
output$plot1<-renderPlot({
rules <- apriori(transaction_all[[as.numeric(input$level)]],parameter=list(support=input$support,confidence=input$confidence))
plot(rules, measure=c("support", "lift"), shading="confidence",interactive = TRUE)
})
})

0 个答案:

没有答案