'Extract a value from reactive data frame in shiny

I am not sure how I extract a value from a reactive data frame and use it for calculation. The reactive output did not show up so I could not calculate what I want it the end. When I run the script below, I got an error as "$ operator is invalid for atomic vector"

Exercise<-c(A,B,C)
Var1<-c(60,90,50)
Var2<-c(0.5,0.7,0.3)

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(numericInput(inputId = "Time1",
                              label = "Duration:",
                              min = 0,
                              max = 120,
                              value = 1),
                 selectInput(
                   inputId = "Drill1",
                   label = "Drill1",
                   choices = Exercise,
                   selected = "1")
    ),
    mainPanel(h3(textOutput("Power"))
    )
  )
)


server <- function(input, output) {
  d<- reactive({
    res<-T1 %>%
      filter(Exercise == input$Drill1)
    res
  })
  
  output$Power <- renderPrint({
    dataset <-d()
    Int<-dataset$Var1[dataset$Exercise == input$Drill1]
    results<-Time1*Int
    results
  })
}

I really appreciate your help in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source