anytime – dates in R
This article is originally published at https://aghaynes.wordpress.com
I just saw an announcement on R Bloggers about the anytime package. It looks to be a very handy package to convert dates in pretty much any format to Date or POSIX classes, without the need to define the format – it’s guessed by an underlying C++ library.
It certainly seems to be flexible… putting in the same date in 8 different formats all yielded the same result! (FWIW, “15th October 2010” doesn’t work…)
> anytime::anydate(c("2010-10-15", "2010-Oct-15", + "20101015", "15 Oct 2010", + "10-15-2010", "15 October 2010", + "15oct2010", "2010oct15", "15th October 2010")) [1] "2010-10-15" "2010-10-15" "2010-10-15" "2010-10-15" "2010-10-15" "2010-10-15" [7] "2010-10-15" "2010-10-15" NA
There’s an equivalent function for times (anytime instead of anydate). Looks like working with dates and times just got easier!
Thanks for visiting r-craft.org
This article is originally published at https://aghaynes.wordpress.com
Please visit source website for post related comments.