0
votes

I am trying to built a shiny website but i am getting this error: Error in .getReactiveEnvironment()$currentContext() : Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)

my code:

library(shiny)
library(shinydashboard)
library(plotly)

ui <- dashboardPage(
dashboardHeader(title = "Basic Dashboard"),
dashboardSidebar(
sidebarMenu(
  menuItem('Dashboard', tabName = 'dashboard', icon = icon('dashboard'))
  
)
),
dashboardBody(
tabItems(
  tabItem(tabName = 'dashboard',
          fluidRow(
            box(plotlyOutput('plot1', height = 250)),
            box(title = 'Speed', numericInput('numeric1', "Numeric input" , value = 0, min = 0, max = 
  25))
          
  )
  )
  )
  )
  )


  server <- function(input, output) {

  input$numeric1
  output$plot1 <- renderPlotly({
  p <- plot_ly(x= cars$speed, y = cars$dist, type = 'scatter', mode = 'lines')
  })
  } 


 shinyApp(ui, server)
1

1 Answers

0
votes

You need to move input$numeric1 into a reactive for this to work.

The following line should make the app works:

 input_numeric <- reactive( input$numeric1)