For each row of the data.frame main.data, find the index of the matching element in vector ids
Useful links