我有一个闪亮的selectInput面板。直到现在,我只处理selectInput中的选项的固定值。根据闪亮的其他条件改变selectinput中的选项R
现在我想要根据闪亮的Ui中的其他条件来改变这些选择。
例子:
Ui.R
shinyUI(fluidPage(
fluidRow(column(3,
wellPanel(
h4("Data Upload"),
fileInput('file1', h5('Choose Your Model Data'), accept=c('text/csv','text/comma-separated-values,text/plain','.OUT')),
fileInput('file2', h5('Choose Your Observation Data'), accept=c('text/csv','text/comma-separated-values,text/plain','.xlsx'))
),
wellPanel(uiOutput("check"))))
Server.R
shinyServer(function(input, output) {
output$check <- renderUI({
selectInput("check", label = h4("Dataset Selection"), choices = c("Model" = 1, "Observation" = 2, "Both" = 3), selected = 1, multiple = F)
})
a <- reactive({
fileinput1 <- input$file1
if (is.null(fileinput1))
return(NULL)
read.table(fileinput1$datapath, header = TRUE, col.names = c("Ei","Mi","hours","Nphy","Cphy","CHLphy","Nhet","Chet","Ndet","Cdet","DON","DOC","DIN","DIC","AT","dCCHO","TEPC","Ncocco","Ccocco","CHLcocco","PICcocco","par","Temp","Sal","co2atm","u10","dicfl","co2ppm","co2mol","pH"))
})
#Upload Observation Data
b <- reactive({
fileinput2 <- input$file2
if (is.null(fileinput2))
return(NULL)
#xlfile <- list.files(pattern = ".xlsx")
xlfile <- fileinput2[1]
wb <- loadWorkbook(xl_file)
sheet_ct <- wb$getNumberOfSheets()
b <- rbindlist(pblapply(1:sheet_ct, function(x) {
res <- read.xlsx(xl_file, x)
}), fill=TRUE)
b <- b [-c(1),]
print (b)
})
现在,我想使基于文件输入selectInput动态的选择。
见'?updateSelectInput'及其家人的函数来处理这些问题。再看看'?conditionalPanel'。 – nicola 2014-10-27 10:06:26
我已经尝试updateselectinput并没有实时更新选择列表....它就像用户上传文件1我需要更新选择列表基于那只是“模型”...如果他然后上传第二个文件然后提供所有三个选项..如果只是第二个文件上传,然后选择=只是“观察”。请让我知道如何实现这一点。 – statisticalbeginner 2014-10-27 14:27:08