Hi all
I upload a file to the Shiny, this is a file with always the same format, so the date of the extracted data is always in the same cell.
As an extra control, I want to display the date after the file is uploaded, but I don't get it and I don't get an error.
This is the UI code of that section:
sidebarLayout(
sidebarPanel(
fileInput("import", "Choose TXT/CSV File", accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
p("The data of the datafile is:"),
verbatimTextOutput("output$date"),
p("Please ...
)
This is the server part of that section:
server = shinyServer(function(input, output,session){
observeEvent(input$import, {
file1 <- input$import
server_data <- read.delim(file=file1$datapath, header = TRUE, na.strings=c(""," ","NA"))
#Create a subset of the data to remove/exclude the unnecessary columns:
subset_data_server <- server_data[,c(-5,-7,-9,-17,-25:-31)]
#Remove the rows with blank/NA values:
df1 <- na.omit(subset_data_server)
#The difference between the ResultTime and the FirstScanTime is the turn around time:
df1$TS_start <- paste(df1$FirstScanDate, df1$FirstScanTime)
df1$TS_end <- paste(df1$ResultDate, df1$ResultTime)
df1$TAT <- difftime(df1$TS_end,df1$TS_start,units = "mins")
output$date <- renderText({
as.character(server_data[2, server_data$FirstScanDate])
})
...
The output$date is in the "obserEvent()" function, so it should be calculated after a file is uploaded.
Can you help me?
Thank you!