From deffec0bc478166e4d64c1aaefebc6dc6a701077 Mon Sep 17 00:00:00 2001 From: seakintruth Date: Mon, 2 Aug 2021 21:38:26 -0400 Subject: [PATCH 1/2] updates hitcounter to faster .feather file format from .rdata --- ShinyAppVisitorHitCounter/server.R | 29 ++++++++++++++++------------- counter.feather | Bin 0 -> 176 bytes 2 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 counter.feather 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 diff --git a/counter.feather b/counter.feather new file mode 100644 index 0000000000000000000000000000000000000000..76955c417e7a3c0297b0d5e797427b4053285b3e GIT binary patch literal 176 zcmZ>Bbu?r^00$8;n~woR^DwY5Z~$pOAQk{(CLm@6Vh{k)Ftq|ubs!xewLCy<0F?*n t_sA@9&M(a?0W#r0fI)$Q9mwMVn=An)fm|+-dJurw1LMyCin#&Z3IJb42eSYG literal 0 HcmV?d00001 From 67fac3a6cfde0bd5b2c534cd0122d8c4b55ed95a Mon Sep 17 00:00:00 2001 From: seakintruth Date: Mon, 2 Aug 2021 21:47:38 -0400 Subject: [PATCH 2/2] updates hitcounter to feather format --- ShinyAppVisitorHitCounter/counter.Rdata | Bin 66 -> 0 bytes counter.feather | Bin 176 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ShinyAppVisitorHitCounter/counter.Rdata delete mode 100644 counter.feather diff --git a/ShinyAppVisitorHitCounter/counter.Rdata b/ShinyAppVisitorHitCounter/counter.Rdata deleted file mode 100644 index d44eb3e396e5765dc3a3dce8cbcd97fdb94b8003..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 66 zcmb2|=3oE=X6~X+gGXHtk`fXUk`maQ)Y23tw{m(I7;P{pV9NaV$^TXpjH67YZlx9 diff --git a/counter.feather b/counter.feather deleted file mode 100644 index 76955c417e7a3c0297b0d5e797427b4053285b3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 176 zcmZ>Bbu?r^00$8;n~woR^DwY5Z~$pOAQk{(CLm@6Vh{k)Ftq|ubs!xewLCy<0F?*n t_sA@9&M(a?0W#r0fI)$Q9mwMVn=An)fm|+-dJurw1LMyCin#&Z3IJb42eSYG