How to make a contingency table for a shiny application

1k views Asked by At

How can I develop a contingency table in my r studio shiny application.

1

There are 1 answers

0
zero323 On BEST ANSWER

You can convert it to data.frame using as.data.frame.matrix and then render as any other table:

library(shiny)

shinyApp(
    ui=shinyUI(bootstrapPage(
        tableOutput('foo')
    )),
    server=shinyServer(function(input, output, session) {
        output$foo <- renderTable({
            as.data.frame.matrix(table(c(1, 1, 1, 2, 3), c(2, 2, 3, 4, 3)))
        })
    })
)