Optimize loop for index creation in R

I have a dataframe with records of trawl stations in different regions. I need to create a sequential index that changes every time the region changes. I’ve implemented it with a for loop, but I have about 60000 records, so it’s super slow. Any idea on how to do it faster? Please note that I… Read More Optimize loop for index creation in R