Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed ShinyAppVisitorHitCounter/counter.Rdata
Binary file not shown.
29 changes: 16 additions & 13 deletions ShinyAppVisitorHitCounter/server.R
Original file line number Diff line number Diff line change
@@ -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({
Expand Down Expand Up @@ -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)
})

})
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)
})
})