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.