Given data.table dt:
dt <- structure(list(V1 = c("1544018118438041139", "1544018118466235879",
"1544018118586849680", "1544018118601169211", "1544018118612947335",
"1544018118614422179"), V2 = c("162", "162", "161.05167", "158.01309",
"157", "157"), V3 = c("38", "38", "36.051697", "33.01306", "32",
"32"), V4 = c("0.023529414", "0.025490198", "0.023529414", "0.027450982",
"0.03137255", "0.03137255"), V5 = c("1", "1", "1", "1", "1",
"1"), V6 = c("2131230815", "2131230815", "2131230815", "2131230815",
"2131230815", "2131230815"), V7 = c("1", "0", "0", "0", "0",
"-1")), class = c("data.table", "data.frame"), row.names = c(NA,
-6L), .internal.selfref = <pointer: 0x2715f60>)
I want the first column to be bit64::as.integer64()
and the rest of the columns as.numeric()
I am trying to do this:
dt <- dt[ ,V1 := bit64::as.integer64(V1)]
dt[, lapply(.SD, as.numeric), .SDcols = -c("V1")]
But it doesn't seem to do what I want, please advise how to change specific columns to class A(integer64
) and the rest to another class B (say as.numeric()
)?