データ
v1 <- c("2015-01-05 15:00:00", "2015-01-05 15:45:00", "2015-01-05 15:00:30")
オペレーション
v2 <- strptime(v1, '%Y-%m-%d %H:%M:%S')
str(v2)
POSIXlt[1:3], format: "2015-01-05 15:00:00" "2015-01-05 15:45:00" "2015-01-05 15:00:30"
v3 <- v2[!v2$min] # create v3 from v2 eliminating min != 00
RESULT (サブセット化の成功)
str(v3)
POSIXlt[1:2], format: "2015-01-05 15:00:00" "2015-01-05 15:00:30"
v2 を POSIXct に強制して v4 を作成中 (成功)
v4 <- as.POSIXct(v2, format = "%y/%m/%d %H:%M")
str(v4)
POSIXct[1:3], format: "2015-01-05 15:00:00" "2015-01-05 15:45:00" "2015-01-05 15:00:30"
問題の操作 - POSIXlt と同じサブセット操作を POSIXct に適用すると、以下のエラーが発生します。
v5 <- v4[!v4$min] # reassign v2 eliminating min != 00
結果(エラー)
Error in v4$min : $ operator is invalid for atomic vectors
質問:
a) なぜこの動作の違いがあるのですか?
b) POSIXct で使用する同等の操作は何ですか?
どうもありがとう