If i have an "observeEvent" in another R script, my "source()" just does not work.
For example:
UI:
library(shiny)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
actionButton("plot", "Calculate!")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
))
Server:
library(shiny)
source("hahaha.R")
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
observeEvent(input$plot,{
# Create a Progress object
progress <- Progress$new()
progress$set(message = "Buscando dados no banco...", value = 0)
# Close the progress when this reactive exits (even if there's an error)
on.exit(progress$close())
progress$set(value = 0.3)
})
})
hahaha.R:
observeEvent(input$plot,{
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
})
When i run it, just appear:
Listening on http://127.0.0.1:5350
Warning: Error in observeEventExpr: object 'input' not found
58: observeEventExpr
1: runApp