我試圖在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