Skip to content
Prev 367214 / 398506 Next

Confused about using data.table package,

df <- setDT(df) is preferred.
Nope. The "[.data.table" function is very different from the "[.data.frame' function. As you should be able to see, an expression in the `j` position for "[.data.table" gets evaluated in the environment of the data.table object, so unquoted column names get returned after application of any function. Here it's just a unary minus. 

Actually "nope" on two accounts. You cannot use a unary minus for column names in `[.data.frame` either. Would have needed to be df[ , !colnames(df) in "w"]  # logical indexing
I don't see a difference.
You need to do more study of the extensive documentation. The behavior of the ":=" function is discussed in detail there.
It's non-standard for R but many people find the efficiencies of the package worth the extra effort to learn what is essentially a different evaluation strategy.
Rhelp is a plain text mailing list,