How to add subscripts in the row names of a renderTable
? In the following example I need subscripts in A_1
and A_2
.
librar
You can use DT
package for datatable for that. You need to use html tags with escape = FALSE
. Have a look at the modified your code below:
library(shiny)
library(DT)
ui <- fluidPage(dataTableOutput("table"))
server <- function(input, output) {
output$table <- renderDataTable({
data <- datatable(data.frame(c(1, 2), row.names = c("A1", "A2")), rownames = T, escape = FALSE)
})
}
shinyApp(ui = ui, server = server)
You get a table which looks like this:
EDIT:
You can add subscript for renderTable
by using html tags with sanitize.text.function = function(x) x
. The code would be as shown below:
library(shiny)
ui <- fluidPage(tableOutput("table"))
server <- function(input, output) {
output$table <- renderTable({data <- data.frame(c(1, 2),
row.names = c("A1", "A1"))}, rownames = T, sanitize.text.function = function(x) x)}
shinyApp(ui = ui, server = server)
The output table will look as follows:
Hope it helps!