Problem with dplyr filter syntax

Guys,

I'm trying to filter some "choices" in my INPUT based on results of some rows in my dataframe. Look:

aqa

I need to select the AQA_QT values based on GRAU select. Ex.:
For GRAU = X65, the AQA_QT values must be "VD26", "VD51", "VS06" or "VD31".

My code:

 output$iAQA <- renderUI({
    aqas <- my_df$AQA_QT

    filter(my_df,
            GRAU == "input$graudoaco" 
          )

    selectInput(
      "aqadoaco",
      label = "Selecione AQA:",
      choices= aqas,
      multiple = F
    )
  })

That way, it's showing ALL the AQA_QT values. I tried many variations of this code.

How can I do it?
Thx.

You're not providing much context nor have you offered a reproducible example.

If you want to filter the values where GRAU = X65, then filter(my_df, GRAU == "X65") should do the trick.

My hunch is that you want

output$iAQA <- renderUI({

   my_df <- filter(my_df, GRAU == input$graudoaco)

    selectInput(
      "aqadoaco",
      label = "Selecione AQA:",
      choices= my_df$AQA_QT,
      multiple = F
    )
  })

Also, note that filter(my_df, GRAU == "input$graudoaco") is very different from filter(my_df, GRAU == input$graudoaco)

4 Likes

Really thanks man!

You solved my problem. :grinning:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.