4

I am building a shiny app and I need to subset a dataframe based on a user input. I have tried many different ways to do this but I keep running into errors. Currently, this seems to be the simplest method but I get the following error:

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

I am pretty stuck. Does anyone have some guidance for me? Thanks!

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())
  })
})
0

1 Answer 1

8

First, in the subset call you can skip out test$ (not the cause of your problem):

subset(test, MARKET==var)

I suspect your problem is that var is not a string, it is the output of reactive. Try getting the value with var() instead of var

subset(test, MARKET==var())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.