[R] Reporting missing dates
PIKAL Petr
petr@p|k@| @end|ng |rom prechez@@cz
Thu Jan 16 11:35:47 CET 2020
Your approach is quite simple and works well
Another option is
as.Date(setdiff(date_range, d), origin="1970-01-01")
but I do not believe that it has some advantage above yours.
Cheers
Petr
> -----Original Message-----
> From: R-help <r-help-bounces using r-project.org> On Behalf Of Jeff Reichman
> Sent: Wednesday, January 15, 2020 10:28 PM
> To: R-help using r-project.org
> Subject: [R] Reporting missing dates
>
> 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