Goal
To upload a file in a Shiny app that reads the data, name the variables (columns) and do some data analysis before presenting plot output
Reference Shiny App
I am using this app from Shiny gallery as a reference: enter link description here
What I have tried:
I want to use the uploaded data in many outputs after doing different analyses. So, instead of reading file inside renderTable or renderPlot, I read it in server function:
server <- function(input, output) { inFile <- reactive({input$file1}) sdf <- reactive({read.csv(inFile()$datapath, header=F)}) colnames(sdf()) <- c('Vehicle.ID', 'Time', 'Vehicle.class.no', 'Vehicle.type2', 'Vehicle.Length', 'Lane', 'Preceding.Vehicle.ID', 'Spacing','Spacing2', 'State', 'svel.mps', 'deltaV.mps', 'sacc', 'lane.change') } Error
But when I run this app I get:
shiny::runApp('app-CC')
Listening on http://127.0.0.1:7484 Error in colnames(sdf()) <- c("Vehicle.ID", "Time", "Vehicle.class.no", : invalid (NULL) left side of assignment Question
How can I fix this error? I don't want to read the same file again in every render* function. Are there any online examples of shiny apps where a new file is read, column names are defined and then some analysis is done before using the render* functions?
()fromsdf().