Reputation: 1942
This is probably a very easy question but I am still not able to figure out where I'm wrong.
I have to following dataframe
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))
which I am trying to subset with:
Data3[,c("Weight","Date","Factor")]
that unfortunately gives the following result:
[1] "Weight" "Date" "Factor"
instead of selecting a dataframe with the specified columns.
Any hint?
Upvotes: 1
Views: 48
Reputation: 887118
We need to use with = FALSE
as it is a data.table
.
Data3[,c("Weight","Date","Factor"), with = FALSE]
Upvotes: 1