You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might add confusion, but thinking out loud maybe key = TRUE could use the row names as a key by default, or the first column if no row names (the id column will usually be first). This way your first call could be abbreviated to as.data.table(mtcars, key = TRUE)
Hmm but when I read as.data.table(mtcars, key=TRUE), actually I think of the answer being setkey(as.data.tabel(mtcars)); setkey keys on all columns by default.
This works fine:
But it's a bit arcane to know that
rn
is going to be the rownames' name. More readable might be:But that's an error:
Haven't looked yet but it must be setkeyv is applied before the setnames.
Note that this approach already works for
setDT
:The text was updated successfully, but these errors were encountered: