Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render sub/superscript in table (shiny)

I have a datatable in a shiny app, in which I want to add superscript to my observations. These should detail whether the observation is an estimate, and how far the year of the observation is from the reference year (this data is already in my dataset). For example a particular observation might display : "75(superscript)-3 e".

Is this possible?

like image 364
northeastloon Avatar asked Oct 19 '25 10:10

northeastloon


1 Answers

I had the same question today and this post helped me get some of the way there. There is a working example of this on How to add subscripts in the row names of a renderTable (Shiny)? which I have pasted below, with the full acknowledgement that it's not mine!

As follows:

  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("A<sub>1</sub>", "A<sub>2</sub>")), rownames = T, escape = FALSE)
      })
  }

  shinyApp(ui = ui, server = server)

I have tried similar <sub> and <sup> tags in the body of the table and it treats it in the same way.

like image 186
Hester Lyons Avatar answered Oct 21 '25 22:10

Hester Lyons



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!