I'm working on a dashboard with the shiny library and I've managed to create a function that tells me which tab I'm on currently. The problem is that I can't call this function with my other script
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("test"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot"),
# Output: Tabset w/ plot, summary, and table
tabsetPanel(id = "tabs",
tabPanel("Plot", plotOutput("ID1")),
tabPanel("Summary", verbatimTextOutput("ID2")),
tabPanel("Table", tableOutput("ID3")),
)
)
))
# Define server logic required to draw a histogram
server <- function(input, output) {
observeEvent(input$tabs, {
print(paste("You clicked tab:", input$tabs))
})
}
# Run the application
shinyApp(ui, server)
In the other program, I tried to call the function but it didn't succeed.
source("C:/Users/Downloads/Rshiny-intro/RestAPI_TabPanels/App.R")
observeEvent(input$tabs, {
print(paste("You clicked tab:", input$tabs))
})
} ```