Application successfully deployed to https://karenblakemore.shinyapps.io/arules-shinyapp/
Warning message:
In doTryCatch(return(expr), name, parentenv, handler) :
unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':
dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /opt/X11/lib/libSM.6.dylib
Referenced from: /Library/Frameworks/R.framework/Resources/modules//R_X11.so
Reason: image not found
library(shiny)vars <- 5supp <- 0.1conf <- 0.5shinyUI(pageWithSidebar(headerPanel('Association Rules'),sidebarPanel(selectInput('dataset', 'Data Set:', c('titanic' = 'titanic','hospital_readmission' = 'hospital_readmission','PYDATAV3' = 'PYDATAV3')),actionButton('load', 'Load Data Set'), br(), br(),conditionalPanel(condition = "input.samp=='Sample'",numericInput("nrule", 'Number of Rules', 5), br()),conditionalPanel(condition = "input.lhsv=='Subset'",uiOutput("choose_lhs"), br()),conditionalPanel(condition = "input.rhsv=='Subset'",uiOutput("choose_rhs"), br()),conditionalPanel(condition = "input.mytab=='grouped'",sliderInput('k', label='Choose # of rule clusters', min=1, max=150, step=1, value=15), br()),conditionalPanel(condition = "input.mytab %in%' c('scatter', 'twoKeyScatter', 'grouped', 'graph', 'paracoord', 'matrix', 'threeDMatrix', 'datatable')",radioButtons('samp', label='Sample', choices=c('All Rules', 'Sample'), inline=T), br(),uiOutput("choose_columns"), br(),sliderInput("supp", "Support:", min = 0, max = 1, value = supp , step = 1/10000), br(),sliderInput("conf", "Confidence:", min = 0, max = 1, value = conf , step = 1/10000), br(),selectInput('sort', label='Sorting Criteria:', choices = c('lift', 'confidence', 'support')), br(), br(),numericInput("minL", "Min. items per set:", 2), br(),numericInput("maxL", "Max. items per set::", 3), br(),radioButtons('lhsv', label='LHS variables', choices=c('All', 'Subset')), br(),radioButtons('rhsv', label='RHS variables', choices=c('All', 'Subset')), br(),actionButton('generate', 'Generate Association Rules'), br(), br(), br()# downloadButton('downloadData', 'Download Rules as CSV'))),mainPanel(tabsetPanel(id='mytab',tabPanel('ItemFreq', value='itemFreq', plotOutput("itemFreqPlot", width='100%', height='100%')),tabPanel('Scatter', value='scatter', plotOutput("scatterPlot", width='100%', height='100%')),tabPanel('Two-Key Scatter', value='twoKeyScatter', plotOutput("twoKeyScatterPlot", width='100%', height='100%')),tabPanel('Grouped', value='grouped', plotOutput("groupedPlot", width='100%', height='100%')),tabPanel('Graph', value='graph', plotOutput("graphPlot", width='100%', height='100%')),tabPanel('Parallel Coordinates', value='paracoord', plotOutput("paracoordPlot", width='100%', height='100%')),tabPanel('Matrix', value='matrix', plotOutput("matrixPlot", width='100%', height='100%')),tabPanel('3D Matrix', value='threeDMatrix', plotOutput("threeDMatrixPlot", width='100%', height='100%'))# tabPanel('Data Table', value='datatable', dataTableOutput("rulesDataTable"))))))
library(shiny)library(data.table)library(arules)library(arulesViz)shinyServer(function(input, output) {cat(file=stderr(), 'Entered server\n')dataset <- eventReactive(input$load, {cat(file=stderr(), 'Entered load Reactive\n')filename <- paste('./data/', input$dataset, '_features.csv', sep='')data <- read.csv(filename, na.strings=c(''), check.names=FALSE)cat(file=stderr(), 'Loaded features file ', input$dataset, '\n')data[] <- lapply(data, factor) # all columns must be of type factordata})output$choose_columns <- renderUI({checkboxGroupInput("cols", "Choose variables:", choices = colnames(dataset()), selected = colnames(dataset())[1:5])})output$choose_lhs <- renderUI({checkboxGroupInput("colsLHS", "Choose LHS variables:", choices = input$cols, selected = input$cols[1])})output$choose_rhs <- renderUI({checkboxGroupInput("colsRHS", "Choose RHS variables:", choices = input$cols, selected = input$cols[1])})rules <- eventReactive(input$generate, {filename <- paste('data/', input$dataset, '_features.csv', sep='')ds <- read.csv(filename, na.strings=c(''), check.names=FALSE)ds[] <- lapply(ds, factor) # all columns must be of type factortr <- as(ds, 'transactions')arAll <- apriori(tr, parameter=list(support=input$supp, confidence=input$conf, minlen=input$minL, maxlen=input$maxL))if(input$rhsv=='Subset' & input$lhsv!='Subset'){varsR <- character()for(i in 1:length(input$colsRHS)){tmp <- with(ds, paste(input$colsRHS[i], '=', levels(as.factor(get(input$colsRHS[i]))), sep=''))varsR <- c(varsR, tmp)}ar <- subset(arAll, subset=rhs %in% varsR)} else if(input$lhsv=='Subset' & input$rhsv!='Subset') {varsL <- character()for(i in 1:length(input$colsLHS)){tmp <- with(ds, paste(input$colsLHS[i], '=', levels(as.factor(get(input$colsLHS[i]))), sep=''))varsL <- c(varsL, tmp)}ar <- subset(arAll, subset=lhs %in% varsL)} else if(input$lhsv=='Subset' & input$rhsv=='Subset') {varsL <- character()for(i in 1:length(input$colsLHS)){tmp <- with(ds, paste(input$colsLHS[i], '=', levels(as.factor(get(input$colsLHS[i]))), sep=''))varsL <- c(varsL, tmp)}varsR <- character()for(i in 1:length(input$colsRHS)){tmp <- with(ds, paste(input$colsRHS[i], '=', levels(as.factor(get(input$colsRHS[i]))), sep=''))varsR <- c(varsR, tmp)}ar <- subset(arAll, subset=lhs %in% varsL & rhs %in% varsR)} else {ar <- arAll}# Rule lengthnR <- ifelse(input$samp == 'All Rules', length(ar), input$nrule)ar <- sort(ar, by=input$sort)[1:nR]})## Item Frequency Plot ##########################output$itemFreqPlot <- renderPlot({trans <- as(dataset(), 'transactions')itemFrequencyPlot(trans, support=.25, cex.names=0.8)}, height=800, width=800)## Scatter Plot ##########################output$scatterPlot <- renderPlot({plot(rules(), method='scatterplot', engine='htmlwidget')}, height=800, width=800)## Two-Key Scatter Plot ##########################output$twoKeyScatterPlot <- renderPlot({plot(rules(), method='two-key plot', engine='htmlwidget')}, height=800, width=800)## Grouped Plot #########################output$groupedPlot <- renderPlot({plot(rules(), method='grouped', control=list(k=input$k))}, height=800, width=800)## Graph Plot ##########################output$graphPlot <- renderPlot({plot(rules(), method='graph', engine='htmlwidget')}, height=800, width=800)## Parallel Coordinates Plot ###################output$paracoordPlot <- renderPlot({plot(rules(), method='paracoord')}, height=800, width=800)## Matrix Plot ###################output$matrixPlot <- renderPlot({plot(rules(), method='matrix', engine='htmlwidget', shading=c('lift'))}, height=800, width=800)## 3D Matrix Plot ###################output$threeDMatrixPlot <- renderPlot({plot(rules(), method='matrix', engine='3d', shading=c('lift'))}, height=800, width=800)## Rules Data Table ########################### output$rulesDataTable <- renderDataTable({# p <- inspectDT(rules())# htmlwidgets::saveWidget(p, "rules.html", selfcontained = FALSE)# browseURL("rules.html")# })## Download data to csv ######################### output$downloadData <- downloadHandler(# filename = 'arules_data.csv',# content = function(file) {# write.table(as(rules(), 'data.frame'), file, row.names=FALSE, sep=',')# }# )})
a,b,c
11,14,18
10,13,16
12,12,17
12,14,18
11,14,18
11,12,16
11,14,18
11,12,16
12,12,17
11,12,16
12,12,17
12,13,18
11,13,17
11,13,17
10,12,16
11,12,16
10,13,16
10,12,16
11,14,18
12,13,18
11,12,16
11,14,18
11,13,17
11,14,18
12,13,18
10,14,17
12,12,17
10,12,16
12,13,18
12,12,17
10,13,16
12,14,18
11,14,18
10,12,16
10,12,16
10,14,17
11,12,16
10,12,16
12,14,18
12,13,18
11,14,18
12,13,18
10,13,16
11,14,18
11,12,16
12,13,18
10,14,17
12,13,18
11,12,16
10,14,17
11,13,17
11,13,17
12,14,18
10,12,16
10,13,16
12,13,18
12,12,17
12,14,18
12,13,18
10,13,16
11,12,16
11,12,16
11,13,17
10,12,16
12,14,18
10,14,17
12,12,17
10,13,16
11,14,18
10,14,17
12,13,18
11,14,18
10,12,16
output$scatterPlot <- renderPlot({plot(rules(), method='scatterplot', engine='htmlwidget')}, height=800, width=800)