Problem:
The graph plot does not Render. There are no errors.
Description:
Even though I do not use a reactive value below, it should work because it is within an observed event. Rendering a table works perfectly fine.
Additional Info
The AllElements Data is definitely populated! I printed them out to check. They are vectors of type double.
library(shiny)
library(shinyWidgets)
library(shinythemes)
library(datasets)
shinyApp(
ui = navbarPage(
"Real Time Instruments",
############################# Page 1 #############################
tabPanel("Training",
mainPanel(
actionButton("analyse", "Train Model", width = "100%")
)
############################# Page 2 #############################
),
tabPanel("Results",
tableOutput ( "error"),
plotOutput("predict_plot", inline = TRUE)
)
),
server = function(input, output, session) {
### Analyse the data
analyse <- observeEvent(input$analyse , {
# Run the Analysis
AllElements <- data.frame( x = 1:10 )
# populate the results
populateResults (AllElements)
})
#### Results Page ####
populateResults <- function (allElements) {
# First the error table
output$error <- renderTable(allElements$error_sd, digits = 5) ## <--- THIS WORKS!!!
# Second Plots
# par(mar = rep(2, 4)) # Might be needed
x <- allElements$x
xlab <- allElements$x
y <- allElements$x
ylab <- allElements$x
# Plot Predict Var
output$predict_plot <- renderPlot({plot (x, y)}) # <--- THIS DOESN'T WORK!!!
}
})
}
)
I had to change several things in your code.
eventReactive
populateResults
and replaced it by independent render functions error_sd
to the example dataset so that it can be found later in the render functions This example works for me:
library(shiny)
library(shinyWidgets)
library(shinythemes)
library(datasets)
shinyApp(
ui = navbarPage(
"Real Time Instruments",
tabPanel("Training",
mainPanel(
actionButton("analyse", "Train Model", width = "100%")
)
),
tabPanel("Results",
tableOutput ( "error"),
plotOutput("predict_plot")
)
),
server = function(input, output, session) {
analyse <- eventReactive(input$analyse , {
output <- data.frame( x = 1:10 , error_sd = 1:10)
return(output)
})
output$error <- renderTable({
analyse()$error_sd} , digits = 5
)
output$predict_plot <- renderPlot({
# x <- allElements$x
# xlab <- allElements$x
# y <- allElements$x
# ylab <- allElements$x
plot(analyse()$x, analyse()$x)
})
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.