知ってる人は知ってるけど、マニュアルにも明言されていないPOSIXctとPOSIXltの違い。
"POSIXct" is more convenient for including in data frames, and "POSIXlt" is closer to human-readable forms.
・・・って言われてもなあ。
結論から言うと、POSIXctはエポック秒、POSIXltは日付の各項目を名前つきリストで持っているという形式になっているようです。用途に応じて使い分けですね。
> str(unclass(as.POSIXct(Sys.Date()))) num 1.22e+09 > str(unclass(as.POSIXlt(Sys.Date()))) List of 9 $ sec : num 0 $ min : int 0 $ hour : int 0 $ mday : int 7 $ mon : int 7 $ year : int 108 $ wday : int 4 $ yday : int 219 $ isdst: int 0 - attr(*, "tzone")= chr "UTC"
って、地味に超便利だよね・・・。Rで日付の計算なんてそんなにしないのに。ヘタなLLより使いやすいのでは!
追記 Dateクラスについて
Rで日付をあらわすときに使うもうひとつの型であるDateについて。これは、エポック日とでもいうのでしょうか・・・1970-1-1からの日数であらわされています。
> unclass(as.Date("1970-1-1")) [1] 0 > unclass(Sys.Date()) [1] 14100