I'm developing a R + Shiny application. Initially I load a dataset into my memory and slice it depending on the user's input dates.
For example: I download observations for the last 90 days. If the user chooses to see the last 20 days as diagram, I only update the slice of the dataframe the diagram is using for it's calculations.
I'm trying to accomplish this by finding the start-index and end-index of this date and slice accordingly.
startIndex <- grep(startDate, datesVector)
endIndex <- grep(endDate, datesVector)
print(startIndex)
print(endIndex)
data <- data[startIndex:endIndex, ]
Is just working fine locally on my machine. But running on shinyapps.io the print statement will return:
integer(0)
integer(0)
And my app will crash because it can't slice to 0:0. Do you have any advice why grep is behaving differently on these platforms?
[EDIT]: It seems like the conversion of dates from this format
Fri. 22 Aug. 2014
to this one
2014-08-22
with
datesVector <- as.Date(data$Date, "%a. %d %b. %Y")
is working in RStudio and my local browser. However it's not working on shinyapps.io and returning only NAs
Regards