这可能是一个非常简单的问题,但我仍然无法弄清楚我错在哪里。
我必须关注数据框
Data3 <- structure(list(P1 = c("DAVID SKOCH", "VIKTOR TROICKI", "PETER LUCZAK",
"SIMON STADLER", "PHILIPP PETZSCHNER", "JAMIE MURRAY", "MICHAL MERTINAK",
"IGOR KUNITSYN", "DANIEL MUNOZ DE LA NAVA", "ALEXANDRE SIDORENKO"),
P2 = c("LOVRO ZOVKO", "DMITRI SITAK", "MARTIN VASSALLO ARGUELLO",
"SEBASTIEN DE CHAUNAC", "N.SRIRAM BALAJI", "JAROSLAV LEVINSKY",
"STEPHEN AMRITRAJ", "WESLEY MOODIE", "ANDREY GOLUBEV", "NICOLAS TOURTE"),
Date = structure(c(1167618386.44068, 1167619381.13208, 1167622892.30769,
1167626322.58065, 1167627172.88136, 1167629162.26415, 1167635959.32203,
1167636184.61538, 1167638943.39623, 1167643045.16129), tzone = "UTC", class = c("POSIXct","POSIXt")),
Factor = c(0.82, 1.28, 1.37, 1.37, 1.28, 1.28, 1.46, 0.73, 1.82, 1.55), Weight = c(1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1)),
.Names = c("P1", "P2", "Date", "Factor", "Weight"), class = c("data.table", "data.frame"), row.names = c(NA, -10L))
我试图将其分配:
Data3[,c("Weight","Date","Factor")]
不幸的是,给出了以下结果:
[1] "Weight" "Date" "Factor"
而不是选择具有指定列的数据框。
任何提示?
答案 0 :(得分:1)
我们需要使用with = FALSE
,因为它是data.table
。
Data3[,c("Weight","Date","Factor"), with = FALSE]