Consider the below code :
library(data.table)
dataT <-data.table(1:15,runif(15),runif(15),runif(15))
for(vrb in names(dataT)) {
dataT[get(vrb) < 0.5, (vrb):=0.5] # update value
}
As can be inferred from the code, I am basically capping the lowest value of each column to 0.5. To subset rows, I have used get function.
Is this correct way of doing, or is there any other way, which is more aligned with data.table?