Si è verificato un problema perché è in corso l'operazione di osservazione prima che i carichi dell'interfaccia utente vengano caricati.R lucido Osservare in esecuzione Prima del caricamento dell'interfaccia utente e ciò causa i parametri Null
Ecco il mio ui.R
sidebarPanel(
selectInput("Desk", "Desk:" , as.matrix(getDesksUI())),
uiOutput("choose_Product"), #this is dynamically created UI
uiOutput("choose_File1"), #this is dynamically created UI
uiOutput("choose_Term1"), #this is dynamically created UI ....
Ecco il mio Server.R
shinyServer(function(input, output,session) {
#this is dynamic UI
output$choose_Product <- renderUI({
selectInput("Product", "Product:", as.list(getProductUI(input$Desk)))
})
#this is dynamic UI
output$choose_File1 <- renderUI({
selectInput("File1", "File 1:", as.list(getFileUI(input$Desk, input$Product)))
})
#this is dynamic UI and I want it to run before the Observe function so the call
# to getTerm1UI(input$Desk, input$Product, input$File1) has non-null parameters
output$choose_Term1 <- renderUI({
print("Rendering UI for TERM")
print(paste(input$Desk," ", input$Product, " ", input$File1,sep=""))
selectInput("Term1", "Term:", getTerm1UI(input$Desk, input$Product, input$File1))
})
Questo è il mio osservare funzione e viene eseguito prima dell'ingresso $ prodotto e l'ingresso $ File1 sono popolate in modo Ottengo un errore perché entrambi sono NULL. Ma ho bisogno di usare l'input dall'interfaccia utente.
observe({
print("in observe")
print(input$Product)
max_plots<-length(getTerm2UI(input$Desk, input$Product, input$File1))
#max_plots<-5
# Call renderPlot for each one. Plots are only actually generated when they
# are visible on the web page.
for (i in 1:max_plots) {
# Need local so that each item gets its own number. Without it, the value
# of i in the renderPlot() will be the same across all instances, because
# of when the expression is evaluated.
local({
my_i <- i
plotname <- paste("plot", my_i, sep="")
output[[plotname]] <- renderPlot({
plot(1:my_i, 1:my_i,
xlim = c(1, max_plots),
ylim = c(1, max_plots),
main = paste("1:", my_i, ". n is ", input$n, sep = ""))
})
})
}##### End FoR Loop
},priority = -1000)
Qualche idea su come ottenere input $ Product e input $ File1 da compilare PRIMA di osservare le corse?
Grazie.
'observ' ha un argomento' priority = 0'. Un osservatore con un determinato livello di priorità verrà sempre eseguito prima di tutti gli osservatori con un livello di priorità più basso. Puoi dare priorità negativa se vuoi che venga eseguito in un secondo momento. Questo può aiutare. – jdharrison
Ho impostato la priorità a -100 e non succede nulla di diverso – user3022875