我试图在selectInput中显示文件所具有的变量的名称。这个想法是,用户上传应用程序中的文件,他可以选择selectInput中的任何变量。我试图做到这一点,但我没有意识到我的错误。我找到了答案,但它没有帮助我。 Selecting record date with selectInput in shiny RSelectInput在Shiny中的问题
这是Ui.R代码:我没有在我的selectInput中获取名称。
library(shiny)
ui<-fluidPage(
titlePanel(title = "Prueba"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Cargar archivo',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
),
checkboxInput('header', '¿Contiene Encabezado?', TRUE),
radioButtons('sep', 'Delimitador',
c(Comma=',',
"Punto y coma"=';',
Tab='\t'),
','),
radioButtons('quote', 'Quote',
c(Ninguna='',
'Dobles'='"',
'Simples'="'"),
'"'),
radioButtons('resume', 'Summary',
c('Individual',
'Múltiple'),
inline = TRUE),
conditionalPanel("input.resume === 'Individual'",
selectInput('xcol', 'Variable X', names("fileInput$file1"),
selected = names("fileInput$file1")[[1]])
)
),
mainPanel(h3("Muestra del archivo cargado:"),
tableOutput('contents'),
verbatimTextOutput("summary")
)
)
)
你必须阅读server.R的文件,然后使用updateSelectInput()来更新选择输入 – HubertL