How to correct asJSON(keep_vec_names=TRUE) is a named vector?

When running the following code:

library(shiny)
library(tidyverse)

dat1 <- data.frame(
          you = c(3L,1L,1L,1L,1L,2L,2L,3L,3L,5L,2L,
                 1L,3L,2L,1L,1L,3L,1L,1L,1L,2L,3L,3L,3L,3L,1L,1L,
                 1L,1L,1L,1L,1L,1L,1L,3L,1L,1L,1L,6L,1L,5L,3L,
                 3L,2L,1L,2L,7L,3L,1L),
          score = c(2L,1L,3L,5L,2L,3L,5L,5L,5L,1L,4L,
                 1L,5L,3L,4L,4L,2L,3L,5L,4L,3L,2L,5L,4L,3L,3L,2L,
                 3L,3L,4L,2L,3L,3L,5L,2L,3L,3L,4L,4L,3L,4L,3L,
                 3L,3L,3L,1L,4L,2L,4L)
)

ui<- fluidPage(
  
  sidebarLayout(
    sidebarPanel(
      sliderInput(
        inputId = "score",
        label ="This is a test",
        min = 1,
        max = 5,
        value =3
        ),
    ),
  mainPanel(
    plotOutput("bar")
  )
  )
)
  
server<-function(input,output){
  
  output$bar<-renderPlot({
    
    plot_dat<-filter(dat1, Group %in% input$score)
    
    ggplot(
      dat=plot_dat,
      #dat=dat1,
      aes(x= you)) + geom_bar()
  }
  )
  
}

shinyApp(ui = ui, server = server)

This Warning occurs:

Error in filter: In argument: Group %in% input$score… Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.

If I comment out plot_dat<-filter(dat1, Group %in% input$score) and dat=plot_dat, as well as use dat=dat1 in the ggplot, I get the slider and a plot of all of the scores for you as I would expect.

Need some help.

Thanks,
Jeff

I needed a different filter.

plot_dat<-filter(dat1, score==input$score)

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.