Fun-zin
Fun-zin

Reputation: 113

R Shiny(selectizeInput): object "choices" not found

I want to begin by saying that I am new at this. This code was working before, but now it doesn't run anymore. It gives me 'Error : object 'choices' not found' I have tried supplying it with rownames(z$genres),

Any help is appreciated. Thank you in advance!

ui.R

conditionalPanel("sideBarMenu == 'CoordPlot",

                       selectizeInput("genre", "Genre", choices, 
                                      selected = choices[1])
      )

server.R

observe({
 output$barPlot <- renderPlot({
             z %>% filter(genres == input$genre) %>%  group_by(genres, newname2)%>%summarise(value = mean(values)) %>% ggplot(aes(x = newname2, y=value, fill = newname2)) + geom_bar(stat= "identity", width = 1, show.legend = FALSE) + labs(x = "Genre") +  coord_polar() 
   })
)

Upvotes: 3

Views: 599

Answers (1)

Florian
Florian

Reputation: 25405

The function is looking for an object choices, but it is unable to find it. Where is the choices object defined in your code? You should make sure that what you provided as choices contains the unique values for genre, like so:

selectizeInput("genre", "Genre", choices=unique(z$genres))

This should work, provided that the z dataframe is in your environment. It would probably be best to add a file global.R, where you initialize/create the dataframe z.

Upvotes: 1

Related Questions