How to use CRAN package in shinyapps.io?

I am having issues with deploying an app in shinyapps.io. I am using a package from CRAN called DateTimeRangePicker. The app works locally, but the specific package is missing when deployed. The goal is to use this CRAN package in shinyapps.io, which it is not currently doing. I'm not sure if I need to run a specific line of code or if I need to deploy with the CRAN package. I am stumped and was hoping someone could point me in the right direction.

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

not_sel <- "Not selected"

ui <- fluidPage(
  fileInput("csv_input", "Select file", accept = ".csv"),
  selectInput("y_axis", 'Select Variable', choices = c(not_sel), multiple = TRUE),
  DateTimeRangePickerInput('date_range',from = '2024-06-11 14:00:00', to = '2024-06-11 14:00:05'),
  actionButton('run', 'Run'),
  plotOutput('plot')
)

server <- function(input,output){
  options(shiny.maxRequestSize=900*1024^2)
  
  data_input <- reactive({
    req(input$csv_input)
    df <- read.csv(input$csv_input$datapath)
    return(df)
  })
  
  data_input_0 <- reactive({
    data_input() |> mutate(y = lubridate::ymd_hms(timestamp))
    })
  
  data_filtered <- eventReactive(input$run,{
    filter(data_input_0(), as.POSIXct(timestamp) >= as.POSIXct(input$date_range[1]) & as.POSIXct(timestamp) <= as.POSIXct(input$date_range[2]))
  })
  
  observeEvent(data_input(), {
    choices <- c(names(data_input()))
    updateSelectInput(inputId = "y_axis", choices = choices)
  })
  
  output$plot <- renderPlot(
    ggplot(data_filtered(), aes(x = timestamp, y = .data[[input$y_axis]], group = input$y_axis))+geom_point() + geom_line()
  )
}

shinyApp(ui = ui, server = server)

When running your app myself, the package installs no problem, but indeed the time selector fails to appear on shinyapps.io while it works locally.

Firefox's developer console shows this error message:

The resource from “https://me.shinyapps.io/testpicker/_w_9415f45e/reactwidget-2.0.0/react-tools.umd.cjs” was blocked due to MIME type (“application/octet-stream”) mismatch (X-Content-Type-Options: nosniff).

Which appears in line with this report. I believe you have the same problem, that DateTimeRangePicker depends on reactR and the latest version breaks in some situations, specifically on shinyapps.io.

See the linked Github discussion for details.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.