My dataset, named ds, is a matrix with three columns and 4000+ observations. The three columns in ds are:
name v2 f1
- name is character
- v2 is numeric
- f1 is factor with 54 levels
I want to find the position of the min for v2 for factor x. I tried to use tapply as follows
tapply(ds$v2, ds$f1 == x, which.min)
The answer I get is something like this:
FALSE TRUE
2821 19
I presumed that 19 is the absolute position in my dataset and if I want to find the name of the observation all I need to do is
ds[19, 1]
But apparently that is incorrect. I have understood that 19 corresponds to the relative position i.e. it is the 19th observation for factor x.
So my question is: How can I find the absolute position for min value of factor x?