uyos
uyos

Reputation: 5

Can't apply group_by in Shiny

I'm trying to group the generated data of the user based on their choices. Basically, I want the user to have a copy of the "raw" data they generated then show them some summary using group_by and a plot which will be activated by click on a button.

This is the part where I keep getting an error.

                        
  Market_Data <- group_by_(Data, `Market Name`, Year, Month) %>%
                 summarise(Monthly_Price = Price)
                 
  output$MarketPlot <- renderPlot({
              ggplot(Market_Data, mapping = aes(x = Month, y = Monthly_price, color = Commodity)) +
              geom_line(stat = "identity") +
              ylim(min(Market_Data$Price), max(Market_Data$Price))}) ```

#Error Message#
Warning: Error in UseMethod: no applicable method for 'group_by_' applied to an object of class "c('reactiveExpr', 'reactive', 'function')"
  54: group_by_
  50: server [#8]
Error in UseMethod("group_by_") : 
  no applicable method for 'group_by_' applied to an object of class "c('reactiveExpr', 'reactive', 'function')"

I've tried searching for similar scenario but I don't think I've seen one. Appreciate your help. I also forgot to mention that my Data is reactive.

Upvotes: 0

Views: 1524

Answers (1)

YBS
YBS

Reputation: 21287

Try Market_Data <- Data %>% group_by(...)

Upvotes: 2

Related Questions