I'm trying to subset a data.table based on a condition but I want also to get its original row number/s from the data.table. What I read here is that you just need to set the which to TRUE but it only returns the actual row number not with its entire row.
Boston[medv == min(medv), which=TRUE] this one returns [1] 399 406 which means that those row met the condition.
If which is not set to TRUE, i.e. Boston[medv == min(medv)] it returns
crim zn indus chas nox rm age dis rad tax ptratio black lstat medv
1: 38.3518 0 18.1 0 0.693 5.453 100 1.4896 24 666 20.2 396.90 30.59 5
2: 67.9208 0 18.1 0 0.693 5.683 100 1.4254 24 666 20.2 384.97 22.98 5
which it returns the row number differently (i.e. 1 & 2).
What I'm trying to achieve is to look like this,
crim zn indus chas nox rm age dis rad tax ptratio black lstat medv
399: 38.3518 0 18.1 0 0.693 5.453 100 1.4896 24 666 20.2 396.90 30.59 5
406: 67.9208 0 18.1 0 0.693 5.683 100 1.4254 24 666 20.2 384.97 22.98 5
where the row number is 309 and 406.