Skip to content

Instantly share code, notes, and snippets.

@xiaodaigh xiaodaigh/dataset.txt forked from jcheng5/dataset.txt
Last active Dec 22, 2015

Embed
What would you like to do?
item1,item2,item3,item4,item5,item6,item7,item8,item9,item10
1,1,,,1,1,,,,
,,1,1,,,1,1,,
1,,,,1,,,,1,1
,1,,1,1,,1,,1,
1,1,1,1,1,1,,,,1
,1,,,,,1,,,
,,1,1,1,1,,1,,
1,,,1,,,,1,,1
,,1,1,1,,,,1,1
library(arules)
shinyServer(function(input, output, session) {
rules <- reactive({
if (is.null(input$file))
return(NULL)
dataset <- read.csv(input$file$datapath)
#changing data type to factor
for(i in 1:10){
dataset[,i]<-factor(dataset[,i])
}
#generating rules
rules<-apriori(dataset,parameter=list(support=0.20,confidence=0.20,minlen=2))
return(sort(rules))
})
output$rules <- renderPrint({
# This is a little bit of a hack to prevent the output of calculating the
# rules from being displayed in the "rules" verbatimTextOutput output.
capture.output(rules())
if (is.null(rules()))
return(invisible())
inspect(rules())
})
})
shinyUI(pageWithSidebar(
headerPanel("Association Rules"),
sidebarPanel(
fileInput("file", "File")
,selectInput("selectInput1",choices=dir("")[grepl('dir("")','\\.arules$')])
),
mainPanel(
verbatimTextOutput("rules")
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.