I have a data frame (all_data) in which I have a list of sites (1... to n) and their scores e.g.
all_data
site score 1 10 1 11
This should be fairly efficient and understandable:
Dat$sitenum <- match(Dat$site, unique(Dat$site))