0

我需要在闪亮中显示交互式关联规则图。为此,我正在使用 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)
})
})
4

0 回答 0