[R-es] Cargar como choices un dataframe en un checkboxGroupInput [Shiny]
Jesús Para Fernández
j@p@r@@fern@ndez @ending from hotm@il@com
Mie Sep 12 18:30:18 CEST 2018
Buenas,
Lo he resuelto con un renderizado de la User Interface, es decir, pinto desde el server el checkbox entero:
library(shiny)
ui <- fluidPage(
uiOutput("importancia")
)
server <- function(input, output) {
output$importancia <- renderUI({
load("C:/datos/archivo.RData")
variables <- df$variables
as.list(variables)
checkboxGroupInput("n_breaks", label = "Selecciona las variables:",
choices = variables,inline=TRUE)
})
}
shinyApp(ui = ui, server = server)
________________________________
De: R-help-es <r-help-es-bounces using r-project.org> en nombre de Jes�s Para Fern�ndez <j.para.fernandez using hotmail.com>
Enviado: mi�rcoles, 12 de septiembre de 2018 18:03
Para: r-help-es using r-project.org
Asunto: [R-es] Cargar como choices un dataframe en un checkboxGroupInput [Shiny]
Buenas,
Una duda de Shiny. Quiero meter la columna de un data.frame que cargo con un load dentro de un checkbox. Para ello creo lo siguiente:
library(shiny)
ui <- fluidPage(
checkboxGroupInput("n_breaks", label = "Selecciona las variables:",
choices = textOutput("importancia"),inline=TRUE)
)
server <- function(input, output) {
output$importancia <- renderText({
load("C:/datos/archivo.RData")
variables <- df$variable
variables
})
}
shinyApp(ui = ui, server = server)
El data.frame que esta dentro del archivo.RData (el cual adjunto) es:
df <- data.frame(variables = c("uno","dos")
El checkbox en vez de mostrar uno y dos como opciones, muestra names, attrib y children.....
�Alguna idea?
Gracias.
[[alternative HTML version deleted]]
Más información sobre la lista de distribución R-help-es