Last active
January 31, 2021 13:23
-
-
Save jcheng5/6501605 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") | |
), | |
mainPanel( | |
verbatimTextOutput("rules") | |
) | |
)) |
Thanks... Exactly what I was looking for...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This helps a lot. Thank you.