I am getting the following error when I run my data through my script:
Error in filter()
:
! Problem while computing ..1 = SampleDate >= as.Date(paste(year(SampleDate), 3, 15, sep = "-"))
.
Caused by error in charToDate()
:
! character string is not in a standard unambiguous format
My code previously did not have this error prior to the update to Funny Looking Kid. (Is anyone else hating this recent update?) It is a filter that selects a range of dates based on month and day and then pastes the associated year back in to create a date with month, day, and year.
S1 <- S1 %>%
mutate(
year=year(SampleDate), # extract parts
month=month(SampleDate),
day=day(SampleDate)
)
S1 <-S1 %>%
filter(SampleDate >= as.Date(paste(year(SampleDate), 03, 15, sep = "-")),
SampleDate <= as.Date(paste(year(SampleDate), 09, 15, sep = "-")))
I cannot share my data file, but all dates are in Date class and are formatted as 2013-05-07 (YMD)
I have tried resolving this using the anytime package:
S1 <-S1 %>%
filter(SampleDate >= as.Date(paste(year(anydate(SampleDate)), 03, 15, sep = "-")),
SampleDate <= as.Date(paste(year(anydate(SampleDate)), 09, 15, sep = "-")))
and by reformatting in YMD order:
S1 <-S1 %>%
filter(SampleDate >= as.Date(paste(year(SampleDate), sep = "-", 03, 15)),
SampleDate <= as.Date(paste(year(SampleDate), sep = "-", 09, 15)))
I get the same error no matter what I try. I would really appreciate any work around anyone can offer!