I use both routinely, depending on the need. 'ct' is great for
representing date/time holistically (2021-04-26 13:21:27) and is numeric
under the hood in seconds since the big bang (just kidding), kind of
like julian seconds. 'lt' is a list of 7 elements that often require
manipulation (e.g. lt$mon = month of the year starting with Jan = 0) but
it's great for extracting values like day of the year, day of the week,
etc. w/o having to do it yourself - saves a heap of error-fraught
coding. One draw back is the handling of daylight savings shifts. In
March, an hour gets lost (jumps from 0159 to 0300) and in October you
get an hour twice, so if you're using code that requires 1 hour steps,
you get hiccups twice/year, so that requires special handling. Don't
overlook 'strptime' to convert non-standard dates (e.g.
'4/26/21' isn't
recognized by as.POSIXct but strptime can do the conversions for you.)
David Stevens
On 4/26/2021 12:26 PM, Jeff Reichman wrote:> r-help
>
>
>
> Generally speaking is it better to convert date/time values to
"POSIXlt" and
> "POSIXct" objects?
>
>
>
> Jeff Reichman
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
> CAUTION: This email originated from outside of USU. If this appears to be a
USU employee, beware of impersonators. Do not click links, reply, download
images, or open attachments unless you verify the sender?s identity and know the
content is safe.
>