Hi everyone,
Word of warning. I am a complete noob when it comes to Shiny!
I'm currently trying to translate some code I've written into a Shiny app and am having some problems. I've set the app up so that you upload a file (mp3), this is then analysed in some way and chart should display that analysis at the end.
I have it working in a very basic fashion but for some reason it will only render the plot if I resize the Shiny app window?!
Any thoughts or help would be most appreciated.
# Define UI for data upload app ----
ui <- fluidPage(
# App title ----
titlePanel("Uploading Files"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
# Input: Select a file ----
fileInput("file1", "Choose MP3 File",
multiple = TRUE,
accept = c("audio/mp3",
".mp3")),
# Horizontal line ----
tags$hr()
),
# Main panel for displaying outputs ----
mainPanel(
# Output: Data file ----
plotOutput("plot")
)
)
)
# Define server logic to read selected file ----
server <- function(input, output) {
output$plot <- renderPlot({
input$go
# input$file1 will be NULL initially. After the user selects
# and uploads a file, head of that data file by default,
# or all rows if selected, will be shown.
# load in the model
model <<- load_model_hdf5("models/bob_cnn_dropout.h5")
# get the album in the right order
bands <<- c("band 1", "band 2")
req(input$file1)
whom <<- predict_band(input$file1$datapath)
track_name <- input$file1$name
whom %>%
ggplot(aes(pos, is_track, colour = winner)) +
geom_line() +
theme(legend.position = "none") +
scale_colour_gradient(low = "deeppink2", high = "grey35") +
labs(title = track_name)
})
}
Feel free to mock the terrible code, it's all very hacky to get it to work.
Thanks, Chris