Через пр.:
df1 <- structure(list(block = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2),
site = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4), day = c(1,
2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3)), .Names = c("block", "site",
"day"), row.names = c("2", "3", "4", "5", "6", "7", "8", "9",
"10", "11", "12", "13"), class = "data.frame")
df1$site2 <- ave(df1$site,df1$block,FUN=function(x) match(x,sort(unique(x))))