If you need i,j indices to solve your problem you should probably not be using a data.frame but a matrix type.
If you need i,j indices to solve your problem you should probably not be using a data.frame but a matrix type.