Davin Dirgantara
Davin Dirgantara

Reputation: 83

How to Show R Crosstable in Shiny

my server.R

shinyServer(function(input, output) {

output$table0 <- renderPrint({
  confusionMatrix(sms_results$predict_type,
                  sms_results$actual_type, positive = "spam")
})

output$table <- renderDataTable({
  table(sms_results$actual_type, sms_results$predict_type)
})
output$table1 <- renderDataTable({
  CrossTable(sms_test_pred, sms_test_labels,
             prop.chisq = FALSE, prop.t = FALSE, prop.r = FALSE,
             dnn = c('predicted', 'actual'))
})

ui.R

shinyUI(fluidPage(

  # Application title
  titlePanel("Evaluating Model Performance"),


  mainPanel(
    plotOutput("plot"),
    column(12,
           dataTableOutput('table')
    )
  ),
           dataTableOutput('table0')

 )
    )

So, how to external view Crosstable and confusion matrix in shiny?

Upvotes: 1

Views: 1592

Answers (1)

Davin Dirgantara
Davin Dirgantara

Reputation: 83

presuming all global variable loaded and library, runapp with this code uir.r

library(shiny)
    shinyUI(fluidPage(
      # Application title
      titlePanel("Machine Learning - Evaluating Model Performance"),
      br(),br(),

      sidebarLayout(
        sidebarPanel(
          h2("Davin", align = "center"),
          h2("(>..<)", align = "center", style = "color:blue"),
          img(src = "40.png", height = 150, width = 300,style="display: block; margin-left: auto; margin-right: auto;")
        ),

      mainPanel(
        plotOutput("plot"),
        column(12,dataTableOutput('table')),

        h2("Kappa Table", align = "center"),verbatimTextOutput('tabkapp'),

        h2("xTable", align = "center"),verbatimTextOutput('table1'),

        h2("ROC prob", align = "center"),
        column(12,dataTableOutput('tables'))
    ))))
    #  column(12,tableOutput('tables'))

with verbatimtextoutput seems can show this server.r

 shinyServer(function(input, output) {

output$table1 <- renderPrint({
  ctab <- CrossTable(sms_test_pred, sms_test_labels,
             prop.chisq = FALSE, prop.t = FALSE, prop.r = FALSE,
             dnn = c('predicted', 'actual'))

})
    output$tabkapp <- renderPrint({
          tbkp <- Kappa(table(sms_results$actual_type, sms_results$predict_type))
          tbkp
        })
        })

to web external view

output in web external view

output in web external view

any way to make it better ? its on ascii style (i think)... i want it like "datatableoutput" i am okay

Upvotes: 1

Related Questions