Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

349
Views
R-Shiny: cree botones de opción en tablas con columnas seleccionables

Estoy tratando de construir en Shiny una tabla que use botones de opción. Necesito que el diseño sea específico de columna (en lugar de específico de fila que usa el ejemplo). Estaba siguiendo el ejemplo de código aquí: https://rstudio.github.io/DT/011-radio.html . Parece estar funcionando, excepto que no puedo mostrar los resultados en la ventana de salida.

 library(shiny) library(DT) c1 = "This is comment 1" c2 = "This is comment 2" c3 = "This is comment 3" c4 = "This is comment 4" c5 = "This is comment 5" comments = list(c1,c2,c3,c4,c5) ui <- fluidPage( tags$head(tags$style(HTML("#foo.tr.selected {background-color:red}"))), title = 'Radio buttons in a table', DT::dataTableOutput('foo'), verbatimTextOutput('sel') ) server <- function(input, output) { m = matrix( as.character(1:5), nrow = 5, ncol = 1, byrow = FALSE, dimnames = list(comments, LETTERS[1]) ) for (i in seq_len(nrow(m))) { m[i, ] = sprintf( '<input type="radio" name="%s" value="%s"/>', "AValue", m[i, ] ) } m output$foo = DT::renderDataTable( m, escape = FALSE, selection = 'none', server = FALSE, options = list(dom = 't', paging = FALSE, ordering = FALSE), callback = JS("table.cols().every(function(i, tab, col) { var $this = $(this.node()); $this.attr('id', this.data()); $this.addClass('shiny-input-radiogroup'); }); Shiny.unbindAll(table.table().node()); Shiny.bindAll(table.table().node());") ) output$sel = renderPrint({ str(sapply(comments, function(i) input[[i]])) }) } shinyApp(ui = ui, server = server)

Supongo que mi código Javascript de devolución de llamada tiene un error. Probé algunas variaciones diferentes en el código, pero no puedo obtener los resultados del botón de opción. ¡Gracias!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!