Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@xiaodaigh
Forked from jcheng5/dataset.txt
Last active December 22, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiaodaigh/6519678 to your computer and use it in GitHub Desktop.
Save xiaodaigh/6519678 to your computer and use it in GitHub Desktop.
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