1
我想更新我的textOutput每次我做一個動作,我該如何做到這一點?我試過這個,但看起來我錯了。 我只想更新每次出現錯誤時都會顯示的錯誤消息。如果沒有錯誤,它保持空白。更新文本輸出R閃亮
shinyServer(function(input, output, session) {
cube <- NULL
paramTemp <- NULL
message <- ""
observe({
updateSelectInput(session, "choixDim", choices = param[name == input$choixCube, dim][[1]])
updateSelectInput(session, "choixMes", choices = param[name == input$choixCube, mes][[1]])
})
output$ajoutColonneUi <- renderUI({
tagList(
if(input$ajoutColonne != "Aucun"){
textInput("nomCol", "Nom de la colonne créée")
},
switch(input$ajoutColonne,
"Ratio de deux colonnes" = tagList(
selectInput("col1", label = "Colonne 1", choices = input$choixMes),
selectInput("col2", label = "Colonne 2", choices = input$choixMes)
),
"Indice base 100" = selectInput("col", label = "Colonne", choices = input$choixMes),
"Evolution" = selectInput("col", label = "Colonne", choices = input$choixMes)
)
)
})
observeEvent(input$chargerCube,{
debutChargement()
paramTemp <- param[name == input$choixCube]
if(!is.null(input$choixDim) && !is.null(input$choixMes)){
cube <<- creerCube(input$choixDim, input$choixMes, paramTemp$temp, paramTemp$path)
}
else{
message <<- "Erreur : Veuillez selectioner au moins une dimension et une mesure"
}
finChargement()
if(!is.null(cube)){
cat('Cube chargé avec succés ! \n')
output$handlerExport <- downloadHandler(
filename = function(){
paste0("cube_generated_with_shiny_app",Sys.Date(),".csv")
},
content = function(file){
fwrite(cube, file, row.names = FALSE)
}
)
output$boutons <- renderUI({
tagList(
downloadButton("handlerExport", label = "Exporter le cube"),
actionButton("butValider", "Rafraichir la table/le graphique")
)
})
}
})
observeEvent(input$butValider,{
output$pivotTable <- renderRpivotTable({
paramTemp <- param[name == input$choixCube]
rpivotTable(data = cube, aggregatorName = "Sum", vals = input$choixMes[1], cols = paramTemp$temp)
})
})
output$message <- renderText({message})
})
謝謝!
你有沒有試過message() – Sam