I have a working shiny application, but I am changing it so that the input data is reactive - it will update when the underlying data updates. It worked fine when it just read in the data, but now that the data is reactive I am having problems with one of the files (two others work just as expected). The file is a .csv which is exported from a database, and I would like to do a little housekeeping before using - change some names and format some data. The relevant part is:
server.r
W.Data<-reactiveFileReader(2000,session,
"WaterData.csv",read.csv,header=TRUE,as.is=TRUE)
This works fine, but then the next two lines won't work:
names(W.Data())[names(W.Data())=="Visit_Start_Date"]<-"Visit.Date"
W.Data()$Visit.Date<-as.Date(W.Data()$Visit.Date,"%m/%d/%Y")
When i run this I get
Error in W.Data()$VisitDate <- as.Date(W.Data()$VisitDate, "%m/%d/%Y"):
invalid (NULL) left side of assignment
and similar for the other line. What is going on here? Can I do these sort of things with a data.frame
that is read from reactiveFileInput
? I tried changing the names in the underlying .csv file to have underscores rather than spaces, and I tried putting the names()
and as.Date()
in reactive()
expressions, but these made no difference.
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…