我正在尝试编写一个闪亮的应用程序,它将在一些变量的帮助下创建索引。从其中的四个中,我将数据分为三个不同的簇(对应于输出变量NewNumClust)。 确实,创建索引的变量在每个群集之间是不同的。这就是我需要使用条件面板功能的原因。 但是出现此错误消息:
不允许从ShinyOutput对象读取对象。
我想知道有解决方法吗?
第二,第二个错误可能与第一个错误有关:第二个实现器按钮不起作用。
关于代码(我只是给你一部分代码,我希望这足以解决我的问题)。
output$id <- reactive({
if(input$act>0){ if((input$PLUVIO==">2093,05") & (input$ALT < 247) & (input$PENTE < 22) & (input$ALIZEE=="non")){
NewNumClust=1}
else if((input$PENTE > 22) & (input$ALIZEE=="non")){NewNumClust=3}
else {NewNumClust=2}
return(NewNumClust= NewNumClust)
}
})
outputOptions(output,'id', suspendWhenHidden=FALSE)
Data2 <- reactive({
if(input$act>0){
if((input$PLUVIO==">2093,05") & (input$ALT < 247) & (input$PENTE < 22) & (input$ALIZEE=="non")){
NewNumClust=1}
else if((input$PENTE > 22) & (input$ALIZEE=="non")){NewNumClust=3}
else {NewNumClust=2}
print(NewNumClust)
list(NewNumClust= NewNumClust)
}
})
output$table2 <- renderTable({
data.frame(Data2())
})
ui <- shinyUI(pageWithSidebar(
headerPanel("...")
,
sidebarPanel(
wellPanel(
fileInput('file1', 'Choisir un fichier de données espèces présentes dans votre prélèvement', accept=c('text/csv', 'text/tab-separated-values,text/plain','.csv'))
,
selectInput('PLUVIO',"Pluviosité",c("<=1174,6","]1174,6-2093,05]",">2093,05"))
,
numericInput('ALT',"Altitude","")
,
numericInput('PENTE',"Pente","")
,
selectInput('ALIZEE',"Alizee",c("oui","non"))
,
actionButton("act","Actualiser")
)
)
,
mainPanel(
#verbatimTextOutput("id"),
conditionalPanel(
condition="output.id ==1",
#numericInput("Clust", "Cluster ", 1, min = 1, max = 1),
numericInput('Ax',"Année","")
,
numericInput('X1',"Valeur de ETAT_GENERAL","")
,
numericInput('X2',"Valeur de RECOUV_LIGN","")
,
numericInput('X3',"Valeur de Nbr_ESP_APP_20m2","")
,
numericInput('X4',"Valeur de DEGATFOLIAIRE","")
,
numericInput('X5',"Valeur de DEGAT","")
,
numericInput('X6',"Valeur de Nbr_recrues_identique","")
,
numericInput('X7',"Valeur de MOY_HAUT_HERB_UTI","")
,
numericInput('X8',"Valeur de MOY_DIAM_HERB_UTI","")
,
numericInput('X9',"Valeur de MOY_DIAM_LIGN_UTI","")
,
numericInput('X10',"Valeur de MOY_HAUT_LIGN_APP","")
),
conditionalPanel(
condition="output.id ==2",
#numericInput("Clust", "Cluster ", 2, min = 2, max = 2),
numericInput('Ax',"Année","")
,
numericInput('X1',"Valeur de RECOUV_TOT","")
,
numericInput('X2',"Valeur de RECOUV_HERB","")
,
numericInput('X3',"Valeur de Nbr_ESP_APP_20m2","")
,
numericInput('X4',"Valeur de Nbr_ESP_UTI_20m2","")
,
numericInput('X5',"Valeur de MORTALITE","")
,
numericInput('X6',"Valeur de DEGAT","")
,
numericInput('X7',"Valeur de Nbr_recrues_diff","")
,
numericInput('X8',"Valeur de Nbr_recrues_identique","")
,
numericInput('X9',"Valeur de MOY_DIAM_HERB_UTI","")
,
numericInput('X10',"Valeur de MOY_HAUT_HERB_APP","")
),
conditionalPanel(
condition="output.id ==3",
#numericInput("Clust", "Cluster ", 3, min = 3, max = 3),
numericInput('Ax',"Année","")
,
numericInput('X1',"Valeur de MOY_HAUT_HERB_UTI","")
,
numericInput('X2',"Valeur de DEGAT","")
,
numericInput('X3',"Valeur de Nbr_ind_APP_20m2","")
,
numericInput('X4',"Valeur de Nbr_ind_UTI_20m2","")
,
numericInput('X5',"Valeur de RECOUV_LIGN","")
,
numericInput('X6',"Valeur de DIV_SHANN_APP","")
,
numericInput('X7',"Valeur de MOY_DIAM_HERB_UTI","")
,
numericInput('X8',"Valeur de RECOUV_HERB","")
,
numericInput('X9',"Valeur de Nbr_recrues_identique","")
,
numericInput('X10',"Valeur de MOY_DIAM_LIGN_UTI","")
),
actionButton("act","Actualiser"),
tableOutput("table2"),
#tableOutput("table"),
#tableOutput("table1")
)
)
)
shinyApp(ui, server)
请随时问我一些问题,随时与我联系。