I want to change factor levels of a column using setattr
. However, when the column is selected the standard data.table
way (dt[ , col]
It might help to understand if you look at the address from both expressions:
address(d$x)
# [1] "0x10e4ac4d8"
address(d$x)
# [1] "0x10e4ac4d8"
address(d[,x])
# [1] "0x105e0b520"
address(d[,x])
# [1] "0x105e0a600"
Note that the address from the first expression doesn't change when you call it multiple times, while the second expression does which indicates it is making a copy of the column due to the dynamic nature of the address, so setattr
on it will have no effect on the original data.table.