Jesús Para Fernández
2018-Sep-12 16:03 UTC
[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.
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL:
<https://stat.ethz.ch/pipermail/r-help-es/attachments/20180912/a53f9125/attachment.html>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: archivo.RData
Type: application/octet-stream
Size: 2772 bytes
Desc: archivo.RData
URL:
<https://stat.ethz.ch/pipermail/r-help-es/attachments/20180912/a53f9125/attachment.obj>
Jesús Para Fernández
2018-Sep-12 16:30 UTC
[R-es] Cargar como choices un dataframe en un checkboxGroupInput [Shiny]
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 en r-project.org> en nombre de Jes?s Para
Fern?ndez <j.para.fernandez en hotmail.com>
Enviado: mi?rcoles, 12 de septiembre de 2018 18:03
Para: r-help-es en 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]]