POSIXlt
日付を保持するために使用しています。やりたいことは、各日付変数の月日を次のように変更することですが、エラーになります。(以下、d
開催日一覧です。)
> d
[1] "2012-02-01 UTC"
> a = sapply(d, function(x) { x$mday=14;})
Warning messages:
1: In x$mday = 14 : Coercing LHS to a list
2: In x$mday = 14 : Coercing LHS to a list
3: In x$mday = 14 : Coercing LHS to a list
4: In x$mday = 14 : Coercing LHS to a list
5: In x$mday = 14 : Coercing LHS to a list
6: In x$mday = 14 : Coercing LHS to a list
7: In x$mday = 14 : Coercing LHS to a list
8: In x$mday = 14 : Coercing LHS to a list
9: In x$mday = 14 : Coercing LHS to a list
> a
sec min hour mday mon year wday yday isdst
14 14 14 14 14 14 14 14 14
変数の形式が変わることに気付きました。
> class(d)
[1] "POSIXlt" "POSIXt"
> a = sapply(d, function(x) { format(x, format = "%Y-%m-%d")})
> a
sec min hour mday mon year wday yday isdst
"0" "0" "0" "14" "1" "112" "0" "91" "0"
フォローしてもらうにはどうしたらいいですか
> d
[1] "2012-02-14 UTC"
などの方法format
を試しました。as.POSIXlt
何も機能しませんでした。