R Shiny App breaks down when sourcing script for data import

Chonasi Source

I am using Shiny on an Amazon web server (ubuntu 14.04.05). I have installed Dropbox on the server and I wrote an application that visualizes data of data frame.

The data frame results from a script that reads all Excel files in a dropbox folder and converts them to a dataframe, while adding additional columns.

I have created an actionButton to source this script from within my shiny application but unfortunately the app breaks down showing the following error message:

Warning: Error in [<-.data.frame: replacement has 2882 rows, data has 2884

My shiny server looks like:

server <- function(input, output) {

load("/home/ubuntu/Dropbox/HTM/df.Rda")
load("/home/ubuntu/Dropbox/HTM/df_predict.Rda")

observeEvent(input$button,{
   source("PreparationServerHTM.R", local=TRUE)
})

And the sourced script:

###Load required libraries
library(lubridate)
library(timeDate)
library(data.table)
library(timeSeries)
library(readxl)

##########################################################################
## Load Excel Sheets as Data Frames 
 files <- (Sys.glob("/home/ubuntu/Dropbox/HTM/*.xlsx"))

 listOfFiles <- lapply(files, function(x) read_xlsx(x, sheet= 1, col_names = 
 TRUE))

 df1 <- as.data.frame(listOfFiles[1])

 for(i in 2:length(listOfFiles)){
 df_temp <- as.data.frame(listOfFiles[i])
 df1 <- rbind(df1, df_temp)
 }

 save(df, file="/home/ubuntu/Dropbox/HTM/df1.Rda")

As you can see, right now the sourcing script aims for creating a dataframe with a different name but even this does not work. Of course, in the future, I want the output of the source script to replace the data of the shiny app and to update the app.

rubuntushinydropbox

Answers

comments powered by Disqus