次の data.table があります。
dt=structure(list(a = c("10", "10", "20", "30", "10", "25", "10"
), b = c("0.605887455840394", "0", "0.709466017509524", "0",
"0.585528817843856", "-0.109303314681054", "-0.453497173462763"
), c = c("-0.919322002474128", "0", "0.630098551068391", "0",
"-1.81795596770373", "-0.276184105225216", "-0.284159743943371"
), d = c("-0.750531994502331", "0", "1.81731204370422", "0",
"-0.116247806352002", "0.370627864257954", "0.520216457554957"
), e = c("0.298723699267293", "0", "-0.886357521243213", "0",
"0.816899839520583", "-0.331577589942552", "1.12071265166956"
), key = c("A", "A", "B", "B", "C", "C", "C")), .Names = c("a",
"b", "c", "d", "e", "key"), row.names = c(NA, -7L), class = c("data.table",
"data.frame"), sorted = "key")
これにより、以下に示すようなデータテーブルが得られます。
a b c d e key
1: 10 0.605887455840394 -0.919322002474128 -0.750531994502331 0.298723699267293 A
2: 10 0 0 0 0 A
3: 20 0.709466017509524 0.630098551068391 1.81731204370422 -0.886357521243213 B
4: 30 0 0 0 0 B
5: 10 0.585528817843856 -1.81795596770373 -0.116247806352002 0.816899839520583 C
6: 25 -0.109303314681054 -0.276184105225216 0.370627864257954 -0.331577589942552 C
7: 10 -0.453497173462763 -0.284159743943371 0.520216457554957 1.12071265166956 C
すべてゼロの行を削除するサブセット操作を実行したいと思います。
私はその線に沿って何かを考えていました
dt[!(all(i[2:4) == 0)]
しかし、data.tableで実際にそれを述べる方法がわかりません
これについて何か助けていただければ幸いです。