diff --git a/ShinyAppVisitorHitCounter/counter.Rdata b/ShinyAppVisitorHitCounter/counter.Rdata deleted file mode 100644 index d44eb3e..0000000 Binary files a/ShinyAppVisitorHitCounter/counter.Rdata and /dev/null differ diff --git a/ShinyAppVisitorHitCounter/server.R b/ShinyAppVisitorHitCounter/server.R index 8dfe859..2c34c4f 100644 --- a/ShinyAppVisitorHitCounter/server.R +++ b/ShinyAppVisitorHitCounter/server.R @@ -1,9 +1,12 @@ library(shiny) +library(feather) # use the below options code if you wish to increase the file input limit, in this example file input limit is increased from 5MB to 9MB # options(shiny.maxRequestSize = 9*1024^2) + shinyServer(function(input,output){ + # This reactive function will take the inputs from UI.R and use them for read.table() to read the data from the file. It returns the dataset in the form of a dataframe. # file$datapath -> gives the path of the file data <- reactive({ @@ -41,16 +44,16 @@ shinyServer(function(input,output){ tabsetPanel(tabPanel("About file", tableOutput("filedf")),tabPanel("Data", tableOutput("table")),tabPanel("Summary", tableOutput("sum"))) }) - output$counter <- - renderText({ - if (!file.exists("counter.Rdata")) - counter <- 0 - else - load(file="counter.Rdata") - counter <- counter + 1 - save(counter, file="counter.Rdata") - paste("Hits: ", counter) - }) - - -}) \ No newline at end of file + output$counter <- renderText({ + if (!file.exists("counter.feather")) { + counter <-as.data.frame(0) + names(counter) <- "HitCount" + } else { + feather::read_feather(path="counter.feather") + } + counter$HitCount <- counter$HitCount + 1 + feather::write_feather(x=counter,path= "counter.feather") + paste("Hits: ", counter$HitCount) + }) +}) + \ No newline at end of file