I ended up with a big data.table and I have to do operations per row. (yes... I know that this is clearly not what data.table are for)
R) set.seed(1)
R) DT=d
Since you already have the row numbers as a column in your data.table*, you could just do:
DT[, `:=`(a1 = max(.SD), a2 = min(.SD)), by = a, .SDcols = paste0("V", 1:10)]
or
setkey(DT, a)
DT[J(a), `:=`(a1 = max(.SD), a2 = min(.SD)), .SDcols = paste0("V", 1:10)]
The second option uses the silent by-without-by.
*of course you could also just use row.names or 1:nrow(DT)