1
我想知道reactiveValue和全局变量之间有什么区别。全局变量和无效值之间的差别
我无法找到一个正确的答案:/和我在下面的脚本有一个问题:
shinyServer(function(input, output, session) {
global <- list()
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()
global <- creerCube(input)
global <- ajouterColonne(global, input)
finChargement()
if(!is.null(global)){
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(global$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({
cat('test')
rpivotTable(data = global$cube, aggregatorName = "Sum", vals = global$mes[1], cols = global$temp)
})
})
})
全球不被更新时,我想显示这些数据rpivotTable ...
反应变量很有用,但如果您只需要更新全局变量的值,请在反应表达式或子函数内使用“<< - '运算符而不是'<-'。 – Geovany