R Shiny - a subset of data based on reactive input

I am creating a brilliant application and I need a subset of a DataFrame based on user input. I have tried many different ways to do this, but I constantly run into errors. Currently, this seems to be the easiest method, but I get the following error:

Warning in is.na (e2): is.na () applies to not (list or vector) of type "closure" Error in ==.default(test $ MARKET, var): comparison (1) is possible only for atomic and types of lists

I'm pretty stuck. Does anyone have any guidance for me? Thank!

library(shiny)

shinyServer(function(input, output) {

      var <- reactive({input$var})

      subsetTest <- subset(test, test$MARKET==var)

      y <- subsetTest()$PRICE
      x <- subsetTest()$DATE

  output$ngplot <- renderPlot({
    print(ggplot(data=subsetTest(), aes(x=y, y=x)) + geom_line())
  })
})
+4
source share
1 answer

-, subset test$ ( ):

subset(test, MARKET==var)

, , var , reactive. var() var

subset(test, MARKET==var())
+8

Source: https://habr.com/ru/post/1538657/


All Articles