App not working on shinyapps.io - "could not find function '%>%'"

Hi!
I've built my first app using Shiny, but I can't get it to work on the shinapps.io website (it works fine in Rstudio). The log says "Warning: Error in %>%: could not find function "%>%"". I have dplyr loaded, so I'm not sure why it doesn't work or how to get around this issue.
The code is:

library(shiny)
library(ggplot2)
library(dplyr)

data(mtcars)

ui <- fluidPage(
  titlePanel("Data collection"),
  sidebarLayout(
    sidebarPanel(
      uiOutput("mtcars2")
    ),
    mainPanel(
      plotOutput("hist"),
      br(), br()
    )
  )
)
server <- function(input, output) {
  output$mtcars2 <- renderUI({
    selectInput("cars", "gear",
                sort(unique(mtcars$gear)),
                selected = "3")
  })  
  
  filtered <- reactive({
    if (is.null(input$cars)) {
      return(NULL)
    }    
    
    mtcars %>%
      filter(gear == input$cars
      )
  })
  
  output$hist <- renderPlot({
    if (is.null(filtered())) {
      return()
    }
    ggplot(filtered(), aes(carb)) +
      geom_histogram()
  })
}
shinyApp(ui=ui,server=server)

Any help would be very much appreciated! Thank you.

You might have loaded dplyr in your local R session but you are not loading it on the app code, so when it gets deployed it runs on a different R session where dplyr is not loaded (or at least that's what you are showing on your sample code).

thanks for taking the time to answer! I have
library(dplyr)
in my app.R code. Is that enough, or is there somewhere else it should be, too?

It should be but enough but that is not what you are showing and we can't reproduce your issue. To help us help you, could you please prepare a proper reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one for a shiny app

sorry about that! I've edited the main text to show a reprex using mtcars.

I know this is super late but the forward piping function %>% is actually part of the 'magrittr' package. I ran into this same issue and after installing and adding the library I had no further issues.