[R] Reporting missing dates
Jim Lemon
drj|m|emon @end|ng |rom gm@||@com
Wed Jan 15 22:45:44 CET 2020
Hi Jeff,
As I'm sure you realize, that only tells you whether a date is within
the range that you have specified. Do you only want to find dates
within a certain range:
new_date<-as.Date("2020-01-10")
new_date < min(d) | new_date > max(d)
or maybe whether the text string specifying the date is NA or cannot
be converted to a date?
Jim
On Thu, Jan 16, 2020 at 8:28 AM Jeff Reichman <reichmanj using sbcglobal.net> wrote:
>
> R-help Forum
>
> I have a 20 year data set and I am looking for a way to find missing dates.
> I wrote this and its works, but am wounding if there is a better way?
>
> d <- c('2020-01-01', '2020-01-02', '2020-01-04', '2020-01-05')
> d <- as.Date(d)
> date_range <- seq(min(d), max(d), by = 1)
> date_range[!date_range %in% d]
>
>
> Sincerely
>
> Jeff Reichman
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list