I'm trying to standardize my variables by using a code that I found in a previous question R loop to standardize variables using data.table However, I got an error message, so I'm not sure what the reason is.
standardise = function(x){(x-mean(x, na.rm = TRUE))/sd(x, na.rm = TRUE)} # Define a standardising function
oldcols = c('B', 'ARP') # Name of old columns
newcols = paste0('z_', oldcols) # Name of new columns ('z_B' and 'z_ARP')
QBB_clean[, (newcols) := lapply(.SD, standardise), .SDcols = oldcols]
The error message (Error in
:=((newcols), lapply(.SD, standardise)) : could not find function ":=")