Error in value[[3L]](cond) : arguments imply differing number of rows

Hi,

I'm a newbie to R. I'm trying to create a Shiny app and deploy it to Shinyapps.io.

My app works fine in my local machine but fails whilst being deployed to Shinyapps.io with the below error that has been captured from the Shinyapp.io logs

`Loading required package: ggplot2

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

    last_plot

The following object is masked from ‘package:stats’:

    filter

The following object is masked from ‘package:graphics’:

    layout

Loading required package: xts
Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

Loading required package: TTR
Version 0.4-0 included new data defaults. See ?getSymbols.

Attaching package: ‘data.table’

The following objects are masked from ‘package:xts’:

    first, last

Error in value[[3L]](cond) : 
  arguments imply differing number of rows: 147, 146, 61, 60
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted`

The output of reprex is as below

library(shiny)
#> Warning: package 'shiny' was built under R version 3.5.2
library(plotly)
#> Warning: package 'plotly' was built under R version 3.5.3
#> Loading required package: ggplot2
#> Warning: package 'ggplot2' was built under R version 3.5.1
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout
library(quantmod)
#> Warning: package 'quantmod' was built under R version 3.5.3
#> Loading required package: xts
#> Warning: package 'xts' was built under R version 3.5.3
#> Loading required package: zoo
#> Warning: package 'zoo' was built under R version 3.5.1
#> 
#> Attaching package: 'zoo'
#> The following objects are masked from 'package:base':
#> 
#>     as.Date, as.Date.numeric
#> Loading required package: TTR
#> Warning: package 'TTR' was built under R version 3.5.3
#> Version 0.4-0 included new data defaults. See ?getSymbols.
library(markdown)
#> Warning: package 'markdown' was built under R version 3.5.3
library(data.table) 
#> Warning: package 'data.table' was built under R version 3.5.1
#> 
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:xts':
#> 
#>     first, last
#getwd()
#files_app_1 <- list.files(path = "C:/Users/604637121/Documents/R/Practice/App-1/BUD-Summary-Daily-Trend-1/data/BUD-Daily-Reports",pattern = ".csv")
files_app_1 <- list.files(path = "data/BUD-Daily-Reports",pattern = ".csv")
temp_df1 <- lapply(files_app_1, fread, sep=",")

View(temp_df1)  
#> Error in View(temp_df1): invalid 'x' argument

#Change name of each dataframe in temp_df1 to the name of corresponding csv
names(temp_df1) <- gsub(".csv","",files_app_1)
View(temp_df1)
#> Error in View(temp_df1): invalid 'x' argument

#Remove the Traffic_Month column in each Dataframe of Temp_df1
for (i in names(temp_df1)){temp_df1[[i]] <- temp_df1[[i]][,c(2:4)]}

#Create temp_df2 list which contains the Summary values of CDR count and Duartion Mins in each dataframe
temp_df2 <- lapply(names(temp_df1), function(i){aggregate(x = temp_df1[[i]][,1:2], by = list(temp_df1[[i]]$Report_Date), FUN = sum)})


#Change name of each dataframe in temp_df2 to the name of corresponding csv
names(temp_df2) <- gsub (".csv","",files_app_1)

View(temp_df2)
#> Error in View(temp_df2): invalid 'x' argument

# Change column names for each Dataframe in Temp_df2
for (i in names(temp_df2)) {names(temp_df2[[i]]) <- c("Report_Date","CDR_Count","Duration_Mins")}

# Generate a single dataframe by combining the summaries of each Dateframe. This is a Single dataframe of Total CDRs and Duration for each day in BUD

BUD_Daily_Report_Summary_Aggregate <- rbindlist(temp_df2)

View(BUD_Daily_Report_Summary_Aggregate)
#> Error in View(BUD_Daily_Report_Summary_Aggregate): invalid 'x' argument
str(BUD_Daily_Report_Summary_Aggregate)
#> Classes 'data.table' and 'data.frame':   0 obs. of  0 variables
#>  - attr(*, ".internal.selfref")=<externalptr>

#Remove rows with Blank values and NA values in them
BUD_Daily_Report_Summary_Aggregate <- BUD_Daily_Report_Summary_Aggregate[!apply(is.na(BUD_Daily_Report_Summary_Aggregate) | BUD_Daily_Report_Summary_Aggregate == "", 1, all),]

#Change Report_Date column data type from CHR to Date
BUD_Daily_Report_Summary_Aggregate_tmp2 <- as.data.frame(BUD_Daily_Report_Summary_Aggregate, stringsAsFactors = FALSE)
BUD_Daily_Report_Summary_Aggregate_tmp2$Report_Date <- as.Date(BUD_Daily_Report_Summary_Aggregate_tmp2$Report_Date, "%d/%m/%Y")
#> Error in as.Date.default(x, ...): do not know how to convert 'x' to class "Date"

#Sort the dataframe BUD_Daily_Report_Summary_Aggregate_tmp2 in oldest to newest
BUD_Daily_Report_Summary_Aggregate_tmp2 <- BUD_Daily_Report_Summary_Aggregate_tmp2[order(as.Date(BUD_Daily_Report_Summary_Aggregate_tmp2$Report_Date)),]
#> Error in as.Date.default(x, ...): do not know how to convert 'x' to class "Date"
View(BUD_Daily_Report_Summary_Aggregate_tmp2)
#> Error in View(BUD_Daily_Report_Summary_Aggregate_tmp2): invalid 'x' argument
str(BUD_Daily_Report_Summary_Aggregate_tmp2)
#> 'data.frame':    0 obs. of  0 variables
# Create BUD_Daily_Report_Summary_Aggregate_tmp3 dataframe where Report_Date column is sorted in Oldest to Newest

BUD_Daily_Report_Summary_Aggregate_tmp3 <- BUD_Daily_Report_Summary_Aggregate_tmp2[order(as.Date(BUD_Daily_Report_Summary_Aggregate_tmp2$Report_Date, format="%d/%m/%Y")),]
#> Error in as.Date.default(x, ...): do not know how to convert 'x' to class "Date"

View(BUD_Daily_Report_Summary_Aggregate_tmp3)
#> Error in as.data.frame(x): object 'BUD_Daily_Report_Summary_Aggregate_tmp3' not found
str(BUD_Daily_Report_Summary_Aggregate_tmp3)
#> Error in str(BUD_Daily_Report_Summary_Aggregate_tmp3): object 'BUD_Daily_Report_Summary_Aggregate_tmp3' not found

ui <- fluidPage(
  plotlyOutput("plot"),
  verbatimTextOutput("event")
)
server <- function(input, output) {
  output$plot <- renderPlotly({
    plot_ly(BUD_Daily_Report_Summary_Aggregate_tmp3, x = ~Report_Date) %>%
      add_trace(y = ~CDR_Count, name = 'CDR Count',type = 'scatter', mode = 'lines') %>%
      add_trace(y = ~Duration_Mins, name = 'Duration Mins', mode = 'lines+markers') %>%
      layout(
        title = "BUD Summary Daily Trend Dashboard",
        xaxis = list(
          rangeselector = list(
            buttons = list(
              list(
                count = 3,
                label = "3 mo",
                step = "month",
                stepmode = "backward"),
              list(
                count = 6,
                label = "6 mo",
                step = "month",
                stepmode = "backward"),
              list(
                count = 1,
                label = "1 yr",
                step = "year",
                stepmode = "backward"),
              list(
                count = 1,
                label = "YTD",
                step = "year",
                stepmode = "todate"),
              list(step = "all"))),
          
          rangeslider = list(type = "date")),
        
        yaxis = list(title = "Count"))
  })
  output$event <- renderPrint({
    d <- event_data("plotly_hover")
    if (is.null(d)) "Hover on a point!" else d
  })
}
shinyApp(ui, server)

Could you please advise what am I doing wrong.

Thanks & regards
Vish