-
-
Save xiaodaigh/6519678 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | |
}) | |
}) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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