data.table をサブセット化しようとすると、データが失われます。
ファイルが書き込まれる.csvは次のとおりです
Timestamp,Date,Time,SN,A.Ms.Amp,A.Ms.Vol,A.Ms.Watt,Pac
2013-10-01 12:00:00,2013-10-01,12:00:00,2110000001,23.04,465.43,10723,13544.5
2013-10-01 12:00:00,2013-10-01,12:00:00,2110000002,7.81,474.16,3704,6860
2013-10-01 12:00:00,2013-10-01,12:00:00,2110000003,6.97,484.19,3374,6661
2013-10-01 12:05:00,2013-10-01,12:05:00,2110000001,23.19,467.05,10830,13576
2013-10-01 12:05:00,2013-10-01,12:05:00,2110000002,8.4,462.52,3883.5,7366.5
2013-10-01 12:05:00,2013-10-01,12:05:00,2110000003,7.72,470.6,3631,7169
2013-10-01 12:10:00,2013-10-01,12:10:00,2110000001,23.98,470.29,11278.5,14127.5
2013-10-01 12:10:00,2013-10-01,12:10:00,2110000002,8.62,458.47,3952,7475.5
2013-10-01 12:10:00,2013-10-01,12:10:00,2110000003,7.9,462.62,3654,7182.33
2013-10-01 12:15:00,2013-10-01,12:15:00,2110000001,24.27,467.37,11342,14193
2013-10-01 12:15:00,2013-10-01,12:15:00,2110000002,8.61,458.96,3949,7502
2013-10-01 12:15:00,2013-10-01,12:15:00,2110000003,8.13,458.31,3725,7338
2013-10-01 12:20:00,2013-10-01,12:20:00,2110000001,22.3,461.71,10279.5,12735.5
2013-10-01 12:20:00,2013-10-01,12:20:00,2110000002,8.51,461.87,3929,7553.5
2013-10-01 12:20:00,2013-10-01,12:20:00,2110000003,7.83,462.19,3618.5,7331.5
実行したコードは次のとおりです。
library(data.table)
a<-fread("complete1.csv")
a[,`:=`(Timestamp=ymd_hms(Timestamp),
Date=ymd(Date),
SN=as.factor(SN))]
a[SN==c("2110000001","2110000002"),c("Timestamp","Date","Time","SN","A.Ms.Watt","Pac"),with=FALSE]
私はこの出力を得ます:
> a[SN==c("2110000001","2110000002"),c("Timestamp","Date","Time","SN","A.Ms.Watt","Pac"),with=FALSE]
Timestamp Date Time SN A.Ms.Watt Pac
1: 2013-10-01 12:00:00 2013-10-01 12:00:00 2110000001 10723.0 13544.5
2: 2013-10-01 12:00:00 2013-10-01 12:00:00 2110000002 3704.0 6860.0
3: 2013-10-01 12:10:00 2013-10-01 12:10:00 2110000001 11278.5 14127.5
4: 2013-10-01 12:10:00 2013-10-01 12:10:00 2110000002 3952.0 7475.5
5: 2013-10-01 12:20:00 2013-10-01 12:20:00 2110000001 10279.5 12735.5
6: 2013-10-01 12:20:00 2013-10-01 12:20:00 2110000002 3929.0 7553.5
Warning messages:
1: In is.na(e1) | is.na(e2) :
longer object length is not a multiple of shorter object length
2: In `==.default`(SN, c("2110000001", "2110000002")) :
longer object length is not a multiple of shorter object length
残念ながら、私は警告をよく理解していません。しかし、12:xx:x5 間隔ごとにデータが失われています (例: 12:00:05)。私は何が間違っているのでしょうか?