Hi, I'm new to shiny and thought I had a simple example to get started, but output of a matrix/array has been haunting me. I have been looking through the documentation and examples hoping to figure it out myself. But no luck. I'm having trouble with displaying a matrix/array with row names and column names in a shiny main panel.
In R I get to display what is desired:
RateTable
Present Absent Sum
-
"0.0450" "0.0950" "0.1400"
-
"0.0050" "0.8550" "0.8600"
Sum "0.0500" "0.9500" "1.0000"
While in shiny, I get:
Present | Absent | Sum |
---|---|---|
0.0450 | 0.0950 | 0.1400 |
0.0050 | 0.8550 | 0.8600 |
0.0500 | 0.9500 | 1.0000 |
where the row names are missing.
Here is the current app
library(shiny)
ui <- fluidPage(
*Input() functions,
titlePanel("2x2 table properties"),
sidebarLayout(
sidebarPanel(
numericInput("sens", "Sens:", 0.90),
numericInput("spec", "Spec:", 0.90),
numericInput("prev", "Prev:", 0.05),
),
mainPanel(
*Output() functions
tableOutput("myTable")
),
), )
server <- function(input, output ) {
output$myTable <- renderTable( {
RateTable <- matrix( c(# 4 calculated elements here), ncol=2, byrow=TRUE)
colnames(RateTable) <- c("Present", "Absent")
rownames(RateTable) <- c("+", "-")
RateTable <- as.table(RateTable)
RateTable <- addmargins(RateTable)
})
}
Any direction, even to documents I did not find would be appreciated. Thank you. - Jim