Strange error: the table is correctly generated by Rstudio, but not by the site I created

I would like some help from you: The code in shiny below works great. From the dates selected by the daterange (in this case I inserted from 01/11 to 07/11), I can get the averages for Friday and Sunday, as shown in Figure 1. In this case, I'm using the app by RStudio. Later, I deployed this app (<br/>), but when I go to check on the same dates, it doesn't appear Friday, only Sunday (see Figure 2). Do you know what is going on?

Please, if you are unable to reproduce the error, could you tell me what you think it may be, thank you friends!

Code below:

library(shiny)
library(shinythemes)
library(dplyr)
library(tools)
library(DT)

Test <- structure(list(date1 = as.Date(c("2021-11-01","2021-11-01","2021-11-01","2021-11-01")),
                       date2 = as.Date(c("2021-10-22","2021-10-22","2021-10-28","2021-10-30")),
                       Week = c("Friday", "Friday", "Sunday", "Sunday"),
                       Category = c("FDE", "FDE", "FDE", "FDE"),
                       time = c(4, 6, 6, 3)), class = "data.frame",row.names = c(NA, -4L))

ui <- fluidPage(
    
    shiny::navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,
                      br(),
                      tabPanel("",
                               sidebarLayout(
                                   sidebarPanel(
                                       uiOutput('daterange')
                                   ),
                                   mainPanel(
                                       dataTableOutput('table')
                                       
                                   )
                               ))
    ))

server <- function(input, output,session) {
    
    data <- reactive(Test)
    
    output$daterange <- renderUI({
        dateRangeInput("daterange1", "Period you want to see:",
                       min   = min(data()$date1))
    })
    
    observe({updateDateRangeInput(session,"daterange1",start = NA, end = NA)})
    
    wk_port2eng <- data.frame(
        WeekE = c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"),
        WeekP = c("segunda-feira", "terca-feira", "quarta-feira", "quinta-feira",  "sexta-feira", "sabado", "domingo")
    )
    
    data_subset <- reactive({
        req(input$daterange1)
        req(input$daterange1[1] <= input$daterange1[2])
        days <- seq(input$daterange1[1], input$daterange1[2], by = 'day')
        Test1 <- dplyr::filter(data(), date1 %in% days)
        weeks_inp <- unique(weekdays(days))  
        wk <- wk_port2eng[wk_port2eng$WeekP %in% weeks_inp,]  ###  if weekday is in Portuguese in your notebook
        #wk <- wk_port2eng[wk_port2eng$WeekE %in% weeks_inp,]  ###  if weekday is in English in your notebook

        weeks_ine <- wk$WeekE
        meanTest1 <- data() %>%
            group_by(Week = tools::toTitleCase(Week), Category) %>% 
            summarise(mean = mean(time, na.rm = TRUE), .groups = 'drop')
        meanTest <- meanTest1[meanTest1$Week %in% as.character(weeks_ine),]
        meanTest
    })
    
    output$table <- renderDataTable({
        data_subset()
    })
    
}

shinyApp(ui = ui, server = server)

Figure 1

enter image description here

Figure 2

enter image description here

This topic was automatically closed 54 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.