I would like to calculate the standard deviation for each row on a subset of columns. I am using a data table of more than 1 700 000 rows and the function 'apply'.
The line code below takes time :
apply(as.matrix(data[ , .SD, .SDcols = subset_of_columns]), 1, sd, na.rm = TRUE)
Is there an alternative ?
Thank you.