R Brillante: formato condicional de tabla dentro de renderUI

En otroenviar Se ha respondido la misma pregunta asumiendo que la tabla no es parte de una función renderUI.

En el siguiente ejemplo, estoy tratando de ajustar la misma solución (usando JQuery) donde la tabla que quiero formatear condicionalmente pertenece a una función renderUI.

    library(shiny)
    library(datasets)

    script <- "$('tbody tr td:nth-child(5)').each(function() {

              var cellValue = $(this).text();

              if (cellValue > 50) {
                $(this).css('background-color', '#0c0');
              }
              else if (cellValue <= 50) {
                $(this).css('background-color', '#f00');
              }
            })"

  shinyServer(function(input, output, session) {

    session$onFlushed(function() {
      session$sendCustomMessage(type='jsCode', list(value = script))
    })

    output$view <- renderTable({
      head(rock, n = 20)
    })

    output$Test1 <- renderUI({
      list(
        tags$head(tags$script(HTML('Shiny.addCustomMessageHandler("jsCode", function(message) { eval(message.value); });'))),
        tableOutput("view")
      )
    })
  })

  shinyUI(fluidPage(

    tabsetPanel(
      tabPanel("Test1",uiOutput("Test1")),
      tabPanel("Test2")
    )
  ))

En este pequeño ejemplo, el formateo condicional no se aplica a la tabla

Respuestas a la pregunta(2)

Su respuesta a la pregunta